diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-04-29 21:22:04 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-04-29 21:22:04 +0000 |
commit | 826e9831a7f6f1a414d83373d1207c516c88089d (patch) | |
tree | bde22373ebf97f572b5a235c0844d4a51e574b79 /llvm/lib/Analysis | |
parent | 1ffa28a3f1cb1cc61c8937027015a549c60d18dc (diff) | |
download | bcm5719-llvm-826e9831a7f6f1a414d83373d1207c516c88089d.tar.gz bcm5719-llvm-826e9831a7f6f1a414d83373d1207c516c88089d.zip |
[ValueTracking] Make the code in lookThroughCast
No functionality change is intended.
llvm-svn: 268108
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 4097322a2b9..a0a294db521 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3714,29 +3714,22 @@ static Value *lookThroughCast(CmpInst *CmpI, Value *V1, Value *V2, return nullptr; } + Constant *CastedTo = nullptr; + if (isa<ZExtInst>(CI) && CmpI->isUnsigned()) - return ConstantExpr::getTrunc(C, CI->getSrcTy()); + CastedTo = ConstantExpr::getTrunc(C, CI->getSrcTy()); + + if (isa<SExtInst>(CI) && CmpI->isSigned()) + CastedTo = ConstantExpr::getTrunc(C, CI->getSrcTy(), true); if (isa<TruncInst>(CI)) - return ConstantExpr::getIntegerCast(C, CI->getSrcTy(), CmpI->isSigned()); + CastedTo = ConstantExpr::getIntegerCast(C, CI->getSrcTy(), CmpI->isSigned()); if (isa<FPTruncInst>(CI)) - return ConstantExpr::getFPExtend(C, CI->getSrcTy(), true); + CastedTo = ConstantExpr::getFPExtend(C, CI->getSrcTy(), true); if (isa<FPExtInst>(CI)) - return ConstantExpr::getFPTrunc(C, CI->getSrcTy(), true); - - // Sophisticated constants can have values which we cannot easily reason - // about. Skip them for the fp<->int case. - if (isa<ConstantExpr>(C)) - return nullptr; - - Constant *CastedTo = nullptr; - - // This is only valid if the truncated value can be sign-extended - // back to the original value. - if (isa<SExtInst>(CI) && CmpI->isSigned()) - CastedTo = ConstantExpr::getTrunc(C, CI->getSrcTy(), true); + CastedTo = ConstantExpr::getFPTrunc(C, CI->getSrcTy(), true); if (isa<FPToUIInst>(CI)) CastedTo = ConstantExpr::getUIToFP(C, CI->getSrcTy(), true); |