Skip to content

Commit ea602cb

Browse files
committed
[IR] Support or disjoint in hasPoisonGeneratingFlags()
This fixed incorrect removal of freeze instructions.
1 parent ca5a01d commit ea602cb

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/IR/Operator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ bool Operator::hasPoisonGeneratingFlags() const {
3232
case Instruction::AShr:
3333
case Instruction::LShr:
3434
return cast<PossiblyExactOperator>(this)->isExact();
35+
case Instruction::Or:
36+
return cast<PossiblyDisjointInst>(this)->isDisjoint();
3537
case Instruction::GetElementPtr: {
3638
auto *GEP = cast<GEPOperator>(this);
3739
// Note: inrange exists on constexpr only

llvm/test/Transforms/InstSimplify/freeze-noundef.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ define i1 @or(i1 noundef %x, i1 noundef %x2) {
2929
ret i1 %z
3030
}
3131

32-
; FIXME: This is a miscompile.
3332
define i1 @or_disjoint(i1 noundef %x, i1 noundef %x2) {
3433
; CHECK-LABEL: @or_disjoint(
3534
; CHECK-NEXT: [[Y:%.*]] = or disjoint i1 [[X:%.*]], [[X2:%.*]]
36-
; CHECK-NEXT: ret i1 [[Y]]
35+
; CHECK-NEXT: [[Z:%.*]] = freeze i1 [[Y]]
36+
; CHECK-NEXT: ret i1 [[Z]]
3737
;
3838
%y = or disjoint i1 %x, %x2
3939
%z = freeze i1 %y

0 commit comments

Comments
 (0)