[llvm] 5171b7b - [indvars] Common a bit of code [NFC]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 8 15:25:55 PST 2020
Author: Philip Reames
Date: 2020-12-08T15:25:48-08:00
New Revision: 5171b7b40e9813e3fbfaf1e1e3372895c9ff6081
URL: https://github.com/llvm/llvm-project/commit/5171b7b40e9813e3fbfaf1e1e3372895c9ff6081
DIFF: https://github.com/llvm/llvm-project/commit/5171b7b40e9813e3fbfaf1e1e3372895c9ff6081.diff
LOG: [indvars] Common a bit of code [NFC]
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
index c02264aec600..189130f0e0ac 100644
--- a/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyIndVar.cpp
@@ -1272,28 +1272,8 @@ Instruction *WidenIV::cloneArithmeticIVUser(WidenIV::NarrowIVDefUse DU,
}
// 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;
};
@@ -1332,14 +1312,18 @@ WidenIV::ExtendKind WidenIV::getExtendKind(Instruction *I) {
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
More information about the llvm-commits
mailing list