Skip to content

Commit 495ed8d

Browse files
committed
[SLP]Fix PR70507: freeze poisonous insts to avoid poison propagation.
If the reduction instruction is not bool logical op, but reduced within bool logical op reduction list, need to freeze to avoid poison propagation.
1 parent d483abd commit 495ed8d

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14616,15 +14616,15 @@ class HorizontalReduction {
1461614616
Instruction *RedOp1,
1461714617
Instruction *RedOp2,
1461814618
bool InitStep) {
14619-
if (!isBoolLogicOp(RedOp1))
14619+
if (!AnyBoolLogicOp)
1462014620
return;
14621-
if ((!InitStep && LHS == VectorizedTree) ||
14622-
getRdxOperand(RedOp1, 0) == LHS || isGuaranteedNotToBePoison(LHS))
14621+
if (isBoolLogicOp(RedOp1) &&
14622+
((!InitStep && LHS == VectorizedTree) ||
14623+
getRdxOperand(RedOp1, 0) == LHS || isGuaranteedNotToBePoison(LHS)))
1462314624
return;
14624-
if (!isBoolLogicOp(RedOp2))
14625-
return;
14626-
if ((!InitStep && RHS == VectorizedTree) ||
14627-
getRdxOperand(RedOp2, 0) == RHS || isGuaranteedNotToBePoison(RHS)) {
14625+
if (isBoolLogicOp(RedOp2) && ((!InitStep && RHS == VectorizedTree) ||
14626+
getRdxOperand(RedOp2, 0) == RHS ||
14627+
isGuaranteedNotToBePoison(RHS))) {
1462814628
std::swap(LHS, RHS);
1462914629
return;
1463014630
}

llvm/test/Transforms/SLPVectorizer/X86/bool-logical-op-reduction-with-poison.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ define i1 @test(i32 %0, i32 %1, i32 %p) {
1515
; CHECK-NEXT: [[TMP7:%.*]] = call i1 @llvm.vector.reduce.or.v4i1(<4 x i1> [[TMP6]])
1616
; CHECK-NEXT: [[OP_RDX:%.*]] = select i1 [[TMP7]], i1 true, i1 [[CMP6]]
1717
; CHECK-NEXT: [[OP_RDX1:%.*]] = select i1 [[CMP1]], i1 true, i1 [[CMP1]]
18-
; CHECK-NEXT: [[OP_RDX2:%.*]] = select i1 [[OP_RDX]], i1 true, i1 [[OP_RDX1]]
18+
; CHECK-NEXT: [[TMP8:%.*]] = freeze i1 [[OP_RDX]]
19+
; CHECK-NEXT: [[OP_RDX2:%.*]] = select i1 [[TMP8]], i1 true, i1 [[OP_RDX1]]
1920
; CHECK-NEXT: ret i1 [[OP_RDX2]]
2021
;
2122
entry:

0 commit comments

Comments
 (0)