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 | f6ccd2580c14feb4b76239e247ade45898823598 (patch) | |
| tree | a2d9dff1a485044d3af3f356b45000466aa241d4 /llvm/lib/Transforms | |
| parent | 292e98cc182d9f651f8366c0f3670ddf87bb1f6d (diff) | |
| download | bcm5719-llvm-f6ccd2580c14feb4b76239e247ade45898823598.tar.gz bcm5719-llvm-f6ccd2580c14feb4b76239e247ade45898823598.zip | |
"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.
llvm-svn: 51559
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/InstructionCombining.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp index a6cbc201637..20204154d0e 100644 --- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/llvm/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. |

