From 9eb73f9c9d409f35151b0c1e01f1ed95808acd0c Mon Sep 17 00:00:00 2001 From: Matthew Voss Date: Wed, 26 Jul 2023 12:56:02 -0700 Subject: 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 --- llvm/lib/IR/ConstantFold.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'llvm/lib/IR/ConstantFold.cpp') diff --git a/llvm/lib/IR/ConstantFold.cpp b/llvm/lib/IR/ConstantFold.cpp index db1a83b..4c33250 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(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(C1)) { -- cgit v1.1