aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-05 23:36:13 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-05 23:36:13 +0000
commitbaf1e4b91492da97d4d766815c1228e23fcfd97b (patch)
treeceb46dfc5d15792aaafbee6c4944bad8abd72a5f /lib
parent229baffc4e07526176064ca534c3654322c2d3c4 (diff)
downloadexternal_llvm-baf1e4b91492da97d4d766815c1228e23fcfd97b.zip
external_llvm-baf1e4b91492da97d4d766815c1228e23fcfd97b.tar.gz
external_llvm-baf1e4b91492da97d4d766815c1228e23fcfd97b.tar.bz2
Remove an unnecessary if statement and adjust indentation.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34939 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp44
1 files changed, 21 insertions, 23 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index e8de969..8852144 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2407,31 +2407,29 @@ Instruction *InstCombiner::visitUDiv(BinaryOperator &I) {
// udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr X, C2)
// where C1&C2 are powers of two.
- if (SelectInst *SI = dyn_cast<SelectInst>(Op1)) {
+ if (SelectInst *SI = dyn_cast<SelectInst>(Op1))
if (ConstantInt *STO = dyn_cast<ConstantInt>(SI->getOperand(1)))
- if (ConstantInt *SFO = dyn_cast<ConstantInt>(SI->getOperand(2)))
- if (!STO->isNullValue() && !STO->isNullValue()) {
- uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue();
- if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
- // Compute the shift amounts
- unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
- // Construct the "on true" case of the select
- Constant *TC = ConstantInt::get(Op0->getType(), TSA);
- Instruction *TSI = BinaryOperator::createLShr(
- Op0, TC, SI->getName()+".t");
- TSI = InsertNewInstBefore(TSI, I);
-
- // Construct the "on false" case of the select
- Constant *FC = ConstantInt::get(Op0->getType(), FSA);
- Instruction *FSI = BinaryOperator::createLShr(
- Op0, FC, SI->getName()+".f");
- FSI = InsertNewInstBefore(FSI, I);
-
- // construct the select instruction and return it.
- return new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName());
- }
+ if (ConstantInt *SFO = dyn_cast<ConstantInt>(SI->getOperand(2))) {
+ uint64_t TVA = STO->getZExtValue(), FVA = SFO->getZExtValue();
+ if (isPowerOf2_64(TVA) && isPowerOf2_64(FVA)) {
+ // Compute the shift amounts
+ unsigned TSA = Log2_64(TVA), FSA = Log2_64(FVA);
+ // Construct the "on true" case of the select
+ Constant *TC = ConstantInt::get(Op0->getType(), TSA);
+ Instruction *TSI = BinaryOperator::createLShr(
+ Op0, TC, SI->getName()+".t");
+ TSI = InsertNewInstBefore(TSI, I);
+
+ // Construct the "on false" case of the select
+ Constant *FC = ConstantInt::get(Op0->getType(), FSA);
+ Instruction *FSI = BinaryOperator::createLShr(
+ Op0, FC, SI->getName()+".f");
+ FSI = InsertNewInstBefore(FSI, I);
+
+ // construct the select instruction and return it.
+ return new SelectInst(SI->getOperand(0), TSI, FSI, SI->getName());
}
- }
+ }
return 0;
}