mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-03-06 01:19:28 +00:00
Reapply [ConstantFold] Avoid creation of undesirable binop
This was reverted together with another commit due to a test conflict. Reapply without functional changes. ----- When commuting the operands, don't create a constant expression for undesirable binops. Only invoke the constant folding function in that case.
This commit is contained in:
parent
47ba908a5e
commit
90d825be70
@ -1084,7 +1084,9 @@ 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::get(Opcode, C2, C1);
|
||||
return ConstantExpr::isDesirableBinOp(Opcode)
|
||||
? ConstantExpr::get(Opcode, C2, C1)
|
||||
: ConstantFoldBinaryInstruction(Opcode, C2, C1);
|
||||
}
|
||||
|
||||
if (ConstantInt *CI1 = dyn_cast<ConstantInt>(C1)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user