[llvm] r287145 - [InstCombine] fix formatting and add FIXMEs to foldOperationIntoSelectOperand(); NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 12:18:35 PST 2016
Author: spatel
Date: Wed Nov 16 14:18:34 2016
New Revision: 287145
URL: http://llvm.org/viewvc/llvm-project?rev=287145&view=rev
Log:
[InstCombine] fix formatting and add FIXMEs to foldOperationIntoSelectOperand(); NFC
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=287145&r1=287144&r2=287145&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Nov 16 14:18:34 2016
@@ -741,17 +741,16 @@ Value *InstCombiner::dyn_castFNegVal(Val
return nullptr;
}
-static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
+static Value *foldOperationIntoSelectOperand(Instruction &I, Value *SO,
InstCombiner *IC) {
- if (CastInst *CI = dyn_cast<CastInst>(&I)) {
- return IC->Builder->CreateCast(CI->getOpcode(), SO, I.getType());
- }
+ if (auto *Cast = dyn_cast<CastInst>(&I))
+ return IC->Builder->CreateCast(Cast->getOpcode(), SO, I.getType());
// Figure out if the constant is the left or the right argument.
bool ConstIsRHS = isa<Constant>(I.getOperand(1));
Constant *ConstOperand = cast<Constant>(I.getOperand(ConstIsRHS));
- if (Constant *SOC = dyn_cast<Constant>(SO)) {
+ if (auto *SOC = dyn_cast<Constant>(SO)) {
if (ConstIsRHS)
return ConstantExpr::get(I.getOpcode(), SOC, ConstOperand);
return ConstantExpr::get(I.getOpcode(), ConstOperand, SOC);
@@ -761,9 +760,9 @@ static Value *FoldOperationIntoSelectOpe
if (!ConstIsRHS)
std::swap(Op0, Op1);
- if (BinaryOperator *BO = dyn_cast<BinaryOperator>(&I)) {
+ if (auto *BO = dyn_cast<BinaryOperator>(&I)) {
Value *RI = IC->Builder->CreateBinOp(BO->getOpcode(), Op0, Op1,
- SO->getName()+".op");
+ SO->getName() + ".op");
Instruction *FPInst = dyn_cast<Instruction>(RI);
if (FPInst && isa<FPMathOperator>(FPInst))
FPInst->copyFastMathFlags(BO);
@@ -771,10 +770,15 @@ static Value *FoldOperationIntoSelectOpe
}
if (ICmpInst *CI = dyn_cast<ICmpInst>(&I))
return IC->Builder->CreateICmp(CI->getPredicate(), Op0, Op1,
- SO->getName()+".cmp");
+ SO->getName() + ".cmp");
+ // FIXME: This must already be unreachable - we would assert trying to create
+ // an ICmp from an FCmp predicate. It's likely that the ICmp check above this
+ // is also unreachable.
if (FCmpInst *CI = dyn_cast<FCmpInst>(&I))
return IC->Builder->CreateICmp(CI->getPredicate(), Op0, Op1,
- SO->getName()+".cmp");
+ SO->getName() + ".cmp");
+
+ // FIXME: Change this to an assert above.
llvm_unreachable("Unknown binary instruction type!");
}
@@ -827,8 +831,8 @@ Instruction *InstCombiner::FoldOpIntoSel
}
}
- Value *SelectTVal = FoldOperationIntoSelectOperand(Op, TV, this);
- Value *SelectFVal = FoldOperationIntoSelectOperand(Op, FV, this);
+ Value *SelectTVal = foldOperationIntoSelectOperand(Op, TV, this);
+ Value *SelectFVal = foldOperationIntoSelectOperand(Op, FV, this);
return SelectInst::Create(SI->getCondition(), SelectTVal, SelectFVal);
}
More information about the llvm-commits
mailing list