forked from OSchip/llvm-project
[InstCombine] use loop instead of recursion to peek through FPExt; NFCI
llvm-svn: 295992
This commit is contained in:
parent
adf2ab16e4
commit
68e4cb3c86
|
@ -1223,17 +1223,15 @@ static Constant *fitsInFPType(ConstantFP *CFP, const fltSemantics &Sem) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
/// If this is a floating-point extension instruction, look
|
||||
/// through it until we get the source value.
|
||||
/// Look through floating-point extensions until we get the source value.
|
||||
static Value *lookThroughFPExtensions(Value *V) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
if (I->getOpcode() == Instruction::FPExt)
|
||||
return lookThroughFPExtensions(I->getOperand(0));
|
||||
while (auto *FPExt = dyn_cast<FPExtInst>(V))
|
||||
V = FPExt->getOperand(0);
|
||||
|
||||
// If this value is a constant, return the constant in the smallest FP type
|
||||
// that can accurately represent it. This allows us to turn
|
||||
// (float)((double)X+2.0) into x+2.0f.
|
||||
if (ConstantFP *CFP = dyn_cast<ConstantFP>(V)) {
|
||||
if (auto *CFP = dyn_cast<ConstantFP>(V)) {
|
||||
if (CFP->getType() == Type::getPPC_FP128Ty(V->getContext()))
|
||||
return V; // No constant folding of this.
|
||||
// See if the value can be truncated to half and then reextended.
|
||||
|
|
Loading…
Reference in New Issue