Skip to content

Commit 9eb73f9

Browse files
committed
Revert "[ConstantFold] Avoid creation of undesirable binop"
This reverts commit 673a467. Depends on reverted commit 0cab8d2. That commit was reverted due to an LTO crash. I've put a reduced test case here: #64114
1 parent 380dbfd commit 9eb73f9

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

llvm/lib/IR/ConstantFold.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,9 +1084,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
10841084
} else if (isa<ConstantInt>(C1)) {
10851085
// If C1 is a ConstantInt and C2 is not, swap the operands.
10861086
if (Instruction::isCommutative(Opcode))
1087-
return ConstantExpr::isDesirableBinOp(Opcode)
1088-
? ConstantExpr::get(Opcode, C2, C1)
1089-
: ConstantFoldBinaryInstruction(Opcode, C2, C1);
1087+
return ConstantExpr::get(Opcode, C2, C1);
10901088
}
10911089

10921090
if (ConstantInt *CI1 = dyn_cast<ConstantInt>(C1)) {

llvm/test/Transforms/InstCombine/pr32686.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ define void @tinkywinky() {
88
; CHECK-LABEL: @tinkywinky(
99
; CHECK-NEXT: [[PATATINO:%.*]] = load i8, ptr @a, align 1
1010
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i8 [[PATATINO]], 0
11-
; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[TOBOOL_NOT]], icmp ne (ptr @a, ptr @b)
12-
; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32
13-
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP2]], 2
11+
; CHECK-NEXT: [[TMP1:%.*]] = zext i1 [[TOBOOL_NOT]] to i32
12+
; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP1]], or (i32 zext (i1 icmp ne (ptr @a, ptr @b) to i32), i32 2)
1413
; CHECK-NEXT: store i32 [[OR1]], ptr @b, align 4
1514
; CHECK-NEXT: ret void
1615
;

0 commit comments

Comments
 (0)