Skip to content

Commit 26dd128

Browse files
committed
[SLP]Do not propagate nuw/nsw flags for alt nodes, affected by
minbitwidth analysis. Need to drop nuw/nsw flags, if the alternate node is resized after the minbitwidth analysis, to avoid producing poison values in corner cases.
1 parent 3137347 commit 26dd128

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12621,8 +12621,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1262112621
},
1262212622
Mask, &OpScalars, &AltScalars);
1262312623

12624-
propagateIRFlags(V0, OpScalars);
12625-
propagateIRFlags(V1, AltScalars);
12624+
propagateIRFlags(V0, OpScalars, E->getMainOp(), !MinBWs.contains(E));
12625+
propagateIRFlags(V1, AltScalars, E->getAltOp(), !MinBWs.contains(E));
1262612626

1262712627
Value *V = Builder.CreateShuffleVector(V0, V1, Mask);
1262812628
if (auto *I = dyn_cast<Instruction>(V)) {

llvm/test/Transforms/SLPVectorizer/X86/reorder_diamond_match.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ define void @test() {
1111
; CHECK-NEXT: [[TMP6:%.*]] = shl <4 x i16> [[TMP5]], zeroinitializer
1212
; CHECK-NEXT: [[TMP7:%.*]] = add <4 x i16> [[TMP6]], zeroinitializer
1313
; CHECK-NEXT: [[TMP8:%.*]] = shufflevector <4 x i16> [[TMP7]], <4 x i16> poison, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
14-
; CHECK-NEXT: [[TMP9:%.*]] = add nsw <4 x i16> [[TMP7]], [[TMP8]]
15-
; CHECK-NEXT: [[TMP10:%.*]] = sub nsw <4 x i16> [[TMP7]], [[TMP8]]
14+
; CHECK-NEXT: [[TMP9:%.*]] = add <4 x i16> [[TMP7]], [[TMP8]]
15+
; CHECK-NEXT: [[TMP10:%.*]] = sub <4 x i16> [[TMP7]], [[TMP8]]
1616
; CHECK-NEXT: [[TMP11:%.*]] = shufflevector <4 x i16> [[TMP9]], <4 x i16> [[TMP10]], <4 x i32> <i32 1, i32 4, i32 3, i32 6>
17-
; CHECK-NEXT: [[TMP12:%.*]] = add nsw <4 x i16> zeroinitializer, [[TMP11]]
18-
; CHECK-NEXT: [[TMP13:%.*]] = sub nsw <4 x i16> zeroinitializer, [[TMP11]]
17+
; CHECK-NEXT: [[TMP12:%.*]] = add <4 x i16> zeroinitializer, [[TMP11]]
18+
; CHECK-NEXT: [[TMP13:%.*]] = sub <4 x i16> zeroinitializer, [[TMP11]]
1919
; CHECK-NEXT: [[TMP14:%.*]] = shufflevector <4 x i16> [[TMP12]], <4 x i16> [[TMP13]], <4 x i32> <i32 0, i32 1, i32 6, i32 7>
2020
; CHECK-NEXT: [[TMP15:%.*]] = sext <4 x i16> [[TMP14]] to <4 x i32>
2121
; CHECK-NEXT: store <4 x i32> [[TMP15]], ptr [[TMP2]], align 16

0 commit comments

Comments
 (0)