Skip to content

Commit a13148a

Browse files
committed
[SLP]Fix PR75995: drop wrapping flags for resized wrapped binops.
If decided to resize the instruction, need to drop wrapping flags from the resulting vector instructions to avoid incorrect optimizations/assumptions later. Fixes PR75995.
1 parent 7767c58 commit a13148a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11472,7 +11472,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1147211472
Value *V = Builder.CreateBinOp(
1147311473
static_cast<Instruction::BinaryOps>(E->getOpcode()), LHS,
1147411474
RHS);
11475-
propagateIRFlags(V, E->Scalars, VL0);
11475+
propagateIRFlags(V, E->Scalars, VL0, !MinBWs.contains(E));
1147611476
if (auto *I = dyn_cast<Instruction>(V))
1147711477
V = propagateMetadata(I, E->Scalars);
1147811478

llvm/test/Transforms/SLPVectorizer/X86/minbitwidth-drop-wrapping-flags.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define i32 @test() {
1111
; CHECK-NEXT: [[TMP3:%.*]] = or <4 x i8> [[TMP1]], zeroinitializer
1212
; CHECK-NEXT: [[TMP4:%.*]] = shufflevector <4 x i8> [[TMP2]], <4 x i8> [[TMP3]], <4 x i32> <i32 0, i32 1, i32 6, i32 7>
1313
; CHECK-NEXT: [[TMP5:%.*]] = zext <4 x i8> [[TMP4]] to <4 x i16>
14-
; CHECK-NEXT: [[TMP6:%.*]] = add nuw nsw <4 x i16> [[TMP5]], <i16 -1, i16 0, i16 0, i16 0>
14+
; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i16> [[TMP5]], <i16 -1, i16 0, i16 0, i16 0>
1515
; CHECK-NEXT: [[TMP7:%.*]] = call i16 @llvm.vector.reduce.or.v4i16(<4 x i16> [[TMP6]])
1616
; CHECK-NEXT: [[TMP8:%.*]] = zext i16 [[TMP7]] to i32
1717
; CHECK-NEXT: [[TMP9:%.*]] = and i32 [[TMP8]], 65535

0 commit comments

Comments
 (0)