[llvm] r268108 - [ValueTracking] Make the code in lookThroughCast

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 29 14:22:05 PDT 2016


Author: majnemer
Date: Fri Apr 29 16:22:04 2016
New Revision: 268108

URL: http://llvm.org/viewvc/llvm-project?rev=268108&view=rev
Log:
[ValueTracking] Make the code in lookThroughCast

No functionality change is intended.

Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=268108&r1=268107&r2=268108&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Fri Apr 29 16:22:04 2016
@@ -3714,29 +3714,22 @@ static Value *lookThroughCast(CmpInst *C
     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);




More information about the llvm-commits mailing list