diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-05-25 20:56:15 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-05-25 20:56:15 +0000 |
commit | 3dfd7bf5110c47e99fd0fcce96122b90f699ca3a (patch) | |
tree | ca0758bdfa2da8febe3e0e2bc5e69d7523e90f2b /lib/Transforms | |
parent | a5464f3659a721328da98f7096390ac32f9ec6ed (diff) | |
download | external_llvm-3dfd7bf5110c47e99fd0fcce96122b90f699ca3a.zip external_llvm-3dfd7bf5110c47e99fd0fcce96122b90f699ca3a.tar.gz external_llvm-3dfd7bf5110c47e99fd0fcce96122b90f699ca3a.tar.bz2 |
"ret (constexpr)" can't be folded into a Constant. Add a method to
Analysis/ConstantFolding to fold ConstantExpr's, then make instcombine use it
to try to use targetdata to fold constant expressions on void instructions.
Also extend the icmp(inttoptr, inttoptr) folding to handle the case where
int size != ptr size.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51559 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index a6cbc20..2020415 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -11887,6 +11887,16 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) { continue; } + if (TD && I->getType()->getTypeID() == Type::VoidTyID) { + // See if we can constant fold its operands. + for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) { + if (ConstantExpr *CE = dyn_cast<ConstantExpr>(i)) { + if (Constant *NewC = ConstantFoldConstantExpression(CE, TD)) + i->set(NewC); + } + } + } + // See if we can trivially sink this instruction to a successor basic block. // FIXME: Remove GetResultInst test when first class support for aggregates // is implemented. |