Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13859,6 +13859,8 @@ SDValue TargetLowering::expandVECTOR_COMPRESS(SDNode *Node,
SDValue TargetLowering::expandCttzElts(SDNode *Node, SelectionDAG &DAG) const {
SDLoc DL(Node);
EVT VT = Node->getValueType(0);
ElementCount EC =
Node->getOperand(0).getValueType().getVectorElementCount();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a lot of Node->getOperand(0) calls - pull out?


bool ZeroIsPoison = Node->getOpcode() == ISD::CTTZ_ELTS_ZERO_POISON;
auto [Mask, StepVec] =
Expand Down Expand Up @@ -13893,8 +13895,7 @@ SDValue TargetLowering::expandCttzElts(SDNode *Node, SelectionDAG &DAG) const {
if (getTypeAction(StepVT.getSimpleVT()) == TypePromoteInteger)
StepVT = getTypeToTransformTo(*DAG.getContext(), StepVT);

SDValue VL =
DAG.getElementCount(DL, StepVT, StepVecVT.getVectorElementCount());
SDValue VL = DAG.getElementCount(DL, StepVT, EC);
SDValue SplatVL = DAG.getSplat(StepVecVT, DL, VL);
StepVec = DAG.getNode(ISD::SUB, DL, StepVecVT, SplatVL, StepVec);
SDValue Zeroes = DAG.getConstant(0, DL, StepVecVT);
Expand Down
17 changes: 17 additions & 0 deletions llvm/test/CodeGen/X86/intrinsic-cttz-elts.ll
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
; RUN: llc -mtriple=x86_64-unknown-unknown < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-unknown-unknown -mattr=+avx512f < %s | FileCheck %s --check-prefix=AVX512

define i8 @ctz_v8i16(<8 x i16> %a) {
; CHECK-LABEL: .LCPI0_0:
Expand Down Expand Up @@ -101,5 +102,21 @@ define i8 @ctz_v8i16_poison(<8 x i16> %a) {
ret i8 %res
}

define i32 @ctz_zero_v4i1() {
; AVX512-LABEL: ctz_zero_v4i1:
; AVX512: addb $5, %al
%res = call i32 @llvm.experimental.cttz.elts.i32.v4i1(<4 x i1> zeroinitializer, i1 false)
ret i32 %res
}

define i32 @ctz_zero_v8i1() {
; AVX512-LABEL: ctz_zero_v8i1:
; AVX512: addb $9, %al
%res = call i32 @llvm.experimental.cttz.elts.i32.v8i1(<8 x i1> zeroinitializer, i1 false)
ret i32 %res
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These require CHECK coverage as well


declare i8 @llvm.experimental.cttz.elts.i8.v8i16(<8 x i16>, i1)
declare i16 @llvm.experimental.cttz.elts.i16.v4i32(<4 x i32>, i1)
declare i32 @llvm.experimental.cttz.elts.i32.v4i1(<4 x i1>, i1)
declare i32 @llvm.experimental.cttz.elts.i32.v8i1(<8 x i1>, i1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete all 4 of these - we don't need intrinsic forward declarations anymore