Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Analysis/InstructionSimplify.cpp
Show First 20 Lines • Show All 232 Lines • ▼ Show 20 Lines | |||||
/// "(B0 op OtherOp) opex (B1 op OtherOp)". | /// "(B0 op OtherOp) opex (B1 op OtherOp)". | ||||
static Value *expandBinOp(Instruction::BinaryOps Opcode, Value *V, | static Value *expandBinOp(Instruction::BinaryOps Opcode, Value *V, | ||||
Value *OtherOp, Instruction::BinaryOps OpcodeToExpand, | Value *OtherOp, Instruction::BinaryOps OpcodeToExpand, | ||||
const SimplifyQuery &Q, unsigned MaxRecurse) { | const SimplifyQuery &Q, unsigned MaxRecurse) { | ||||
auto *B = dyn_cast<BinaryOperator>(V); | auto *B = dyn_cast<BinaryOperator>(V); | ||||
if (!B || B->getOpcode() != OpcodeToExpand) | if (!B || B->getOpcode() != OpcodeToExpand) | ||||
return nullptr; | return nullptr; | ||||
Value *B0 = B->getOperand(0), *B1 = B->getOperand(1); | Value *B0 = B->getOperand(0), *B1 = B->getOperand(1); | ||||
Value *L = SimplifyBinOp(Opcode, B0, OtherOp, Q, MaxRecurse); | Value *L = SimplifyBinOp(Opcode, B0, OtherOp, Q.getWithoutUndef(), | ||||
MaxRecurse); | |||||
if (!L) | if (!L) | ||||
return nullptr; | return nullptr; | ||||
Value *R = SimplifyBinOp(Opcode, B1, OtherOp, Q, MaxRecurse); | Value *R = SimplifyBinOp(Opcode, B1, OtherOp, Q.getWithoutUndef(), | ||||
MaxRecurse); | |||||
if (!R) | if (!R) | ||||
return nullptr; | return nullptr; | ||||
// Does the expanded pair of binops simplify to the existing binop? | // Does the expanded pair of binops simplify to the existing binop? | ||||
if ((L == B0 && R == B1) || | if ((L == B0 && R == B1) || | ||||
(Instruction::isCommutative(OpcodeToExpand) && L == B1 && R == B0)) { | (Instruction::isCommutative(OpcodeToExpand) && L == B1 && R == B0)) { | ||||
++NumExpand; | ++NumExpand; | ||||
return B; | return B; | ||||
▲ Show 20 Lines • Show All 5,607 Lines • Show Last 20 Lines |