[llvm] 9eb73f9 - Revert "[ConstantFold] Avoid creation of undesirable binop"
Matthew Voss via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 26 12:57:53 PDT 2023
Author: Matthew Voss
Date: 2023-07-26T12:56:31-07:00
New Revision: 9eb73f9c9d409f35151b0c1e01f1ed95808acd0c
URL: https://github.com/llvm/llvm-project/commit/9eb73f9c9d409f35151b0c1e01f1ed95808acd0c
DIFF: https://github.com/llvm/llvm-project/commit/9eb73f9c9d409f35151b0c1e01f1ed95808acd0c.diff
LOG: Revert "[ConstantFold] Avoid creation of undesirable binop"
This reverts commit 673a4671f3e8b7158d990f6456428175a6eac38c.
Depends on reverted commit 0cab8d20417c0e2ccc1ffc5505e080126f5de8e6.
That commit was reverted due to an LTO crash. I've put a reduced
test case here: https://github.com/llvm/llvm-project/issues/64114
Added:
Modified:
llvm/lib/IR/ConstantFold.cpp
llvm/test/Transforms/InstCombine/pr32686.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp
index db1a83bf66204b..4c3325063c09d0 100644
--- a/llvm/lib/IR/ConstantFold.cpp
+++ b/llvm/lib/IR/ConstantFold.cpp
@@ -1084,9 +1084,7 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, Constant *C1,
} else if (isa<ConstantInt>(C1)) {
// If C1 is a ConstantInt and C2 is not, swap the operands.
if (Instruction::isCommutative(Opcode))
- return ConstantExpr::isDesirableBinOp(Opcode)
- ? ConstantExpr::get(Opcode, C2, C1)
- : ConstantFoldBinaryInstruction(Opcode, C2, C1);
+ return ConstantExpr::get(Opcode, C2, C1);
}
if (ConstantInt *CI1 = dyn_cast<ConstantInt>(C1)) {
diff --git a/llvm/test/Transforms/InstCombine/pr32686.ll b/llvm/test/Transforms/InstCombine/pr32686.ll
index f981065bebeb80..acce81a603d2d0 100644
--- a/llvm/test/Transforms/InstCombine/pr32686.ll
+++ b/llvm/test/Transforms/InstCombine/pr32686.ll
@@ -8,9 +8,8 @@ define void @tinkywinky() {
; CHECK-LABEL: @tinkywinky(
; CHECK-NEXT: [[PATATINO:%.*]] = load i8, ptr @a, align 1
; CHECK-NEXT: [[TOBOOL_NOT:%.*]] = icmp eq i8 [[PATATINO]], 0
-; CHECK-NEXT: [[TMP1:%.*]] = or i1 [[TOBOOL_NOT]], icmp ne (ptr @a, ptr @b)
-; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32
-; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP2]], 2
+; CHECK-NEXT: [[TMP1:%.*]] = zext i1 [[TOBOOL_NOT]] to i32
+; CHECK-NEXT: [[OR1:%.*]] = or i32 [[TMP1]], or (i32 zext (i1 icmp ne (ptr @a, ptr @b) to i32), i32 2)
; CHECK-NEXT: store i32 [[OR1]], ptr @b, align 4
; CHECK-NEXT: ret void
;
More information about the llvm-commits
mailing list