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
This commit is contained in:
Nick Lewycky 2007-01-12 01:23:53 +00:00
parent c2a7d097f9
commit 28c5b1544a

View File

@ -1285,8 +1285,17 @@ namespace {
IG.canonicalize(SI->getFalseValue(), Top)) {
add(SI, SI->getTrueValue(), ICmpInst::ICMP_EQ, NewContext);
}
} else if (CastInst *CI = dyn_cast<CastInst>(I)) {
if (CI->getDestTy()->isFPOrFPVector()) return;
if (Constant *C = dyn_cast<Constant>(
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