Skip to content

Commit 8fafd75

Browse files
alexey-bataevgithub-actions[bot]
authored andcommitted
Automerge: [SLP]Drop samesign flag if the vector node has reduced bitwidth
If the operands of the icmp instructions has reduced bitwidth after MinBitwidth analysis, need to drop samesign flag to preserve correctness of the transformation. Fixes #120823
2 parents b8bf499 + 030829a commit 8fafd75

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15483,6 +15483,8 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E, bool PostponedPHIs) {
1548315483
CmpInst::Predicate P0 = cast<CmpInst>(VL0)->getPredicate();
1548415484
Value *V = Builder.CreateCmp(P0, L, R);
1548515485
propagateIRFlags(V, E->Scalars, VL0);
15486+
if (auto *ICmp = dyn_cast<ICmpInst>(V); ICmp && It == MinBWs.end())
15487+
ICmp->setSameSign(/*B=*/false);
1548615488
// Do not cast for cmps.
1548715489
VecTy = cast<FixedVectorType>(V->getType());
1548815490
V = FinalShuffle(V, E);

llvm/test/Transforms/SLPVectorizer/X86/buildvector-schedule-for-subvector.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ define void @test() {
66
; CHECK-NEXT: [[BB:.*:]]
77
; CHECK-NEXT: [[ADD:%.*]] = add i32 1, 0
88
; CHECK-NEXT: [[TMP0:%.*]] = insertelement <4 x i32> <i32 0, i32 0, i32 0, i32 poison>, i32 [[ADD]], i32 3
9-
; CHECK-NEXT: [[TMP1:%.*]] = icmp samesign ult <4 x i32> [[TMP0]], zeroinitializer
9+
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult <4 x i32> [[TMP0]], zeroinitializer
1010
; CHECK-NEXT: [[ICMP:%.*]] = extractelement <4 x i1> [[TMP1]], i32 2
1111
; CHECK-NEXT: [[SELECT:%.*]] = select i1 [[ICMP]], i32 0, i32 0
1212
; CHECK-NEXT: [[ZEXT:%.*]] = zext i32 [[SELECT]] to i64

0 commit comments

Comments
 (0)