}
// WideUse is "WideDef `op.wide` X" as described in the comment.
- const SCEV *WideUse = nullptr;
-
- switch (NarrowUse->getOpcode()) {
- default:
- llvm_unreachable("No other possibility!");
-
- case Instruction::Add:
- WideUse = SE->getAddExpr(WideLHS, WideRHS);
- break;
-
- case Instruction::Mul:
- WideUse = SE->getMulExpr(WideLHS, WideRHS);
- break;
-
- case Instruction::UDiv:
- WideUse = SE->getUDivExpr(WideLHS, WideRHS);
- break;
-
- case Instruction::Sub:
- WideUse = SE->getMinusSCEV(WideLHS, WideRHS);
- break;
- }
+ const SCEV *WideUse =
+ getSCEVByOpCode(WideLHS, WideRHS, NarrowUse->getOpcode());
return WideUse == WideAR;
};
const SCEV *WidenIV::getSCEVByOpCode(const SCEV *LHS, const SCEV *RHS,
unsigned OpCode) const {
- if (OpCode == Instruction::Add)
+ switch (OpCode) {
+ case Instruction::Add:
return SE->getAddExpr(LHS, RHS);
- if (OpCode == Instruction::Sub)
+ case Instruction::Sub:
return SE->getMinusSCEV(LHS, RHS);
- if (OpCode == Instruction::Mul)
+ case Instruction::Mul:
return SE->getMulExpr(LHS, RHS);
-
- llvm_unreachable("Unsupported opcode.");
+ case Instruction::UDiv:
+ return SE->getUDivExpr(LHS, RHS);
+ default:
+ llvm_unreachable("Unsupported opcode.");
+ };
}
/// No-wrap operations can transfer sign extension of their result to their