From 3dfd7bf5110c47e99fd0fcce96122b90f699ca3a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 25 May 2008 20:56:15 +0000 Subject: "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 --- lib/Transforms/Scalar/InstructionCombining.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/Transforms') 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(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. -- cgit v1.1