From 28c5b1544a26adb1008ba445ec62ab69c3db09db Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 12 Jan 2007 01:23:53 +0000 Subject: [PATCH] If we know that it's a constant being casted, propagate through the cast instruction. Doesn't work the other way though (can't recover bits that have been truncated). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33104 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/PredicateSimplifier.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp index 8defb871b76..33dee090986 100644 --- a/lib/Transforms/Scalar/PredicateSimplifier.cpp +++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp @@ -1285,8 +1285,17 @@ namespace { IG.canonicalize(SI->getFalseValue(), Top)) { add(SI, SI->getTrueValue(), ICmpInst::ICMP_EQ, NewContext); } + } else if (CastInst *CI = dyn_cast(I)) { + if (CI->getDestTy()->isFPOrFPVector()) return; + + if (Constant *C = dyn_cast( + IG.canonicalize(CI->getOperand(0), Top))) { + add(CI, ConstantExpr::getCast(CI->getOpcode(), C, CI->getDestTy()), + ICmpInst::ICMP_EQ, NewContext); + } + + // TODO: "%a = cast ... %b" where %b is NE/LT/GT a constant. } - // TODO: CastInst "%a = cast ... %b" where %b is EQ or NE a constant. } /// solve - process the work queue