Skip to content

Commit ff74236

Browse files
committed
[VectorCombine] foldShuffleOfCastops - ensure we add all new instructions onto the worklist
When creating cast(shuffle(x,y)) we were only adding the cast() to the worklist, not the new shuffle, preventing recursive combines. foldShuffleOfBinops is also failing to do this, but I still need to add test coverage for this.
1 parent 61ea1bc commit ff74236

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,8 @@ bool VectorCombine::foldShuffleOfBinops(Instruction &I) {
14401440
NewInst->copyIRFlags(B0);
14411441
NewInst->andIRFlags(B1);
14421442
}
1443+
1444+
// TODO: Add Shuf0/Shuf1 to WorkList?
14431445
replaceValue(I, *NewBO);
14441446
return true;
14451447
}
@@ -1533,6 +1535,7 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) {
15331535
NewInst->andIRFlags(C1);
15341536
}
15351537

1538+
Worklist.pushValue(Shuf);
15361539
replaceValue(I, *Cast);
15371540
return true;
15381541
}

llvm/test/Transforms/VectorCombine/X86/pr67803.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ define <4 x i64> @PR67803(<8 x i32> %x, <8 x i32> %y, <8 x float> %a, <8 x float
88
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt <8 x i32> [[X:%.*]], [[Y:%.*]]
99
; CHECK-NEXT: [[CMP_LO:%.*]] = shufflevector <8 x i1> [[CMP]], <8 x i1> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
1010
; CHECK-NEXT: [[CMP_HI:%.*]] = shufflevector <8 x i1> [[CMP]], <8 x i1> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
11-
; CHECK-NEXT: [[SEXT_LO:%.*]] = sext <4 x i1> [[CMP_LO]] to <4 x i32>
12-
; CHECK-NEXT: [[SEXT_HI:%.*]] = sext <4 x i1> [[CMP_HI]] to <4 x i32>
13-
; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <4 x i32> [[SEXT_LO]], <4 x i32> [[SEXT_HI]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
11+
; CHECK-NEXT: [[TMP0:%.*]] = shufflevector <4 x i1> [[CMP_LO]], <4 x i1> [[CMP_HI]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
12+
; CHECK-NEXT: [[TMP1:%.*]] = sext <8 x i1> [[TMP0]] to <8 x i32>
1413
; CHECK-NEXT: [[CONCAT:%.*]] = bitcast <8 x i32> [[TMP1]] to <4 x i64>
1514
; CHECK-NEXT: [[MASK:%.*]] = bitcast <4 x i64> [[CONCAT]] to <8 x float>
1615
; CHECK-NEXT: [[SEL:%.*]] = tail call noundef <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> [[A:%.*]], <8 x float> [[B:%.*]], <8 x float> [[MASK]])

0 commit comments

Comments
 (0)