Skip to content

Commit 360d723

Browse files
committed
Extend vXi1 setcc to account for intrinsic VT promotion
1 parent b9616cb commit 360d723

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1800,14 +1800,23 @@ SDValue VectorLegalizer::ExpandLOOP_DEPENDENCE_MASK(SDNode *N) {
18001800

18011801
// Create the lane mask
18021802
EVT SplatTY =
1803-
EVT::getVectorVT(*DAG.getContext(), PtrVT, VT.getVectorElementCount());
1803+
EVT::getVectorVT(*DAG.getContext(), PtrVT, VT.getVectorMinNumElements(),
1804+
VT.isScalableVector());
18041805
SDValue DiffSplat = DAG.getSplat(SplatTY, DL, Diff);
18051806
SDValue VectorStep = DAG.getStepVector(DL, SplatTY);
1807+
EVT MaskVT =
1808+
EVT::getVectorVT(*DAG.getContext(), MVT::i1, VT.getVectorMinNumElements(),
1809+
VT.isScalableVector());
18061810
SDValue DiffMask =
1807-
DAG.getSetCC(DL, VT, VectorStep, DiffSplat, ISD::CondCode::SETULT);
1811+
DAG.getSetCC(DL, MaskVT, VectorStep, DiffSplat, ISD::CondCode::SETULT);
18081812

1809-
// Splat the compare result then OR it with the lane mask
18101813
EVT VTElementTy = VT.getVectorElementType();
1814+
// Extend the diff setcc in case the intrinsic has been promoted to a vector
1815+
// type with elements larger than i1
1816+
if (VTElementTy.getScalarSizeInBits() > MaskVT.getScalarSizeInBits())
1817+
DiffMask = DAG.getNode(ISD::ANY_EXTEND, DL, VT, DiffMask);
1818+
1819+
// Splat the compare result then OR it with the lane mask
18111820
if (CmpVT.getScalarSizeInBits() < VTElementTy.getScalarSizeInBits())
18121821
Cmp = DAG.getNode(ISD::ZERO_EXTEND, DL, VTElementTy, Cmp);
18131822
SDValue Splat = DAG.getSplat(VT, DL, Cmp);

llvm/test/CodeGen/AArch64/alias_mask.ll

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ define <16 x i1> @whilewr_8(ptr %a, ptr %b) {
4848
; CHECK-NOSVE-NEXT: uzp1 v1.8h, v2.8h, v3.8h
4949
; CHECK-NOSVE-NEXT: uzp1 v0.16b, v1.16b, v0.16b
5050
; CHECK-NOSVE-NEXT: dup v1.16b, w8
51-
; CHECK-NOSVE-NEXT: shl v0.16b, v0.16b, #7
52-
; CHECK-NOSVE-NEXT: cmlt v0.16b, v0.16b, #0
5351
; CHECK-NOSVE-NEXT: orr v0.16b, v0.16b, v1.16b
5452
; CHECK-NOSVE-NEXT: ret
5553
entry:
@@ -90,8 +88,6 @@ define <8 x i1> @whilewr_16(ptr %a, ptr %b) {
9088
; CHECK-NOSVE-NEXT: uzp1 v0.8h, v0.8h, v1.8h
9189
; CHECK-NOSVE-NEXT: dup v1.8b, w8
9290
; CHECK-NOSVE-NEXT: xtn v0.8b, v0.8h
93-
; CHECK-NOSVE-NEXT: shl v0.8b, v0.8b, #7
94-
; CHECK-NOSVE-NEXT: cmlt v0.8b, v0.8b, #0
9591
; CHECK-NOSVE-NEXT: orr v0.8b, v0.8b, v1.8b
9692
; CHECK-NOSVE-NEXT: ret
9793
entry:
@@ -210,8 +206,6 @@ define <16 x i1> @whilerw_8(ptr %a, ptr %b) {
210206
; CHECK-NOSVE-NEXT: uzp1 v1.8h, v3.8h, v2.8h
211207
; CHECK-NOSVE-NEXT: uzp1 v0.16b, v1.16b, v0.16b
212208
; CHECK-NOSVE-NEXT: dup v1.16b, w8
213-
; CHECK-NOSVE-NEXT: shl v0.16b, v0.16b, #7
214-
; CHECK-NOSVE-NEXT: cmlt v0.16b, v0.16b, #0
215209
; CHECK-NOSVE-NEXT: orr v0.16b, v0.16b, v1.16b
216210
; CHECK-NOSVE-NEXT: ret
217211
entry:
@@ -253,8 +247,6 @@ define <8 x i1> @whilerw_16(ptr %a, ptr %b) {
253247
; CHECK-NOSVE-NEXT: uzp1 v0.8h, v0.8h, v1.8h
254248
; CHECK-NOSVE-NEXT: dup v1.8b, w8
255249
; CHECK-NOSVE-NEXT: xtn v0.8b, v0.8h
256-
; CHECK-NOSVE-NEXT: shl v0.8b, v0.8b, #7
257-
; CHECK-NOSVE-NEXT: cmlt v0.8b, v0.8b, #0
258250
; CHECK-NOSVE-NEXT: orr v0.8b, v0.8b, v1.8b
259251
; CHECK-NOSVE-NEXT: ret
260252
entry:

0 commit comments

Comments
 (0)