mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-04 09:37:20 +00:00
[InstCombine] fix formatting and add FIXMEs to foldOperationIntoSelectOperand(); NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287145 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
42fcf0e528
commit
1c3c35ef97
@ -741,17 +741,16 @@ Value *InstCombiner::dyn_castFNegVal(Value *V, bool IgnoreZeroSign) const {
|
||||
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 *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
|
||||
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 *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
|
||||
}
|
||||
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::FoldOpIntoSelect(Instruction &Op, SelectInst *SI) {
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user