Bill Wendling
a3ba6d3b80
Reduce indentation. No functionality change.
...
llvm-svn: 138968
2011-09-01 21:29:49 +00:00
Bill Wendling
bf8280ff27
Change worklist driven deletion to be an iterative process.
...
Duncan noticed this!
llvm-svn: 138967
2011-09-01 21:28:33 +00:00
Bill Wendling
a617c32745
Resubmit with fix. Properly remove the instructions except for landingpad, which should be removed only when its invokes are.
...
llvm-svn: 138932
2011-09-01 01:28:11 +00:00
Bill Wendling
9f7cf20e60
Submitted this too early.
...
llvm-svn: 138931
2011-09-01 01:18:33 +00:00
Bill Wendling
2d1f11f743
Don't DCE the landingpad instruction.
...
The landingpad instruction can be removed only when its invokes are removed.
llvm-svn: 138930
2011-09-01 01:16:58 +00:00
Bill Wendling
a9ee09f4be
Revert r137655. There is some question about whether the 'landingpad'
...
instruction should be marked as potentially reading and/or writing memory.
llvm-svn: 137863
2011-08-17 20:36:44 +00:00
Bill Wendling
8ddfc09e7a
Use the getFirstInsertionPt() method instead of getFirstNonPHI + an 'isa<>'
...
check for a LandingPadInst.
llvm-svn: 137745
2011-08-16 20:45:24 +00:00
Bill Wendling
91d4e9edec
Don't sink the instruction to before a landingpad instruction.
...
llvm-svn: 137672
2011-08-15 22:53:05 +00:00
Eli Friedman
8bc586e770
Update instcombine for atomic load/store.
...
llvm-svn: 137664
2011-08-15 22:09:40 +00:00
Bill Wendling
e86965ee19
Duncan pointed out that the LandingPadInst might read memory. (It might also
...
write to memory.) Marking it as such makes some checks for immobility go away.
llvm-svn: 137655
2011-08-15 21:14:31 +00:00
Bill Wendling
dd94d3426b
Don't try to sink the landingpad instruction. It's immobile.
...
llvm-svn: 137629
2011-08-15 18:23:40 +00:00
Nick Lewycky
746e317953
This transform is not safe. Thanks to Eli for pointing that out!
...
llvm-svn: 137575
2011-08-14 04:51:49 +00:00
Nick Lewycky
ae13df60a6
Don't attempt to add 'nsw' when intermediate instructions had no such guarantee.
...
llvm-svn: 137572
2011-08-14 03:41:33 +00:00
Nick Lewycky
de49278c26
Teach instcombine to preserve the nsw bit by doing an after-the-fact analysis
...
when combining add and sub instructions. Patch by Pranav Bhandarkar!
llvm-svn: 137570
2011-08-14 01:45:19 +00:00
Nick Lewycky
d405b7e2ae
Small cleanups:
...
- use SmallVectorImpl& for the function argument.
- ignore the operands on the GEP, even if they aren't constant! Much as we
pretend the malloc succeeds, we pretend that malloc + whatever-you-GEP'd-by
is not null. It's magic!
llvm-svn: 136757
2011-08-03 01:11:40 +00:00
Nick Lewycky
50f4966ceb
Fix logical error when detecting lifetime intrinsics.
...
Don't replace a gep/bitcast with 'undef' because that will form a "free(undef)"
which in turn means "unreachable". What we wanted was a no-op. Instead, analyze
the whole tree and look for all the instructions we need to delete first, then
delete them second, not relying on the use_list to stay consistent.
llvm-svn: 136752
2011-08-03 00:43:35 +00:00
Nick Lewycky
e8ae02dfb9
Teach InstCombine that lifetime intrincs aren't a real user on the result of a
...
malloc call.
llvm-svn: 136732
2011-08-02 22:08:01 +00:00
Rafael Espindola
a3a44f3fc3
Add a small gep optimization I noticed was missing while reading some IL.
...
llvm-svn: 136585
2011-07-31 04:43:41 +00:00
Jay Foad
d1b7849d49
Convert GetElementPtrInst to use ArrayRef.
...
llvm-svn: 135904
2011-07-25 09:48:08 +00:00
Jay Foad
040dd82f44
Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to use
...
ArrayRef.
llvm-svn: 135761
2011-07-22 08:16:57 +00:00
Jay Foad
b992a635fb
Convert SimplifyGEPInst to use ArrayRef.
...
llvm-svn: 135482
2011-07-19 15:07:52 +00:00
Frits van Bommel
717d7edd3e
Migrate LLVM and Clang to use the new makeArrayRef(...) functions where previously explicit non-default constructors were used.
...
Mostly mechanical with some manual reformatting.
llvm-svn: 135390
2011-07-18 12:00:32 +00:00
Chris Lattner
229907cd11
land David Blaikie's patch to de-constify Type, with a few tweaks.
...
llvm-svn: 135375
2011-07-18 04:54:35 +00:00
Jay Foad
57aa636794
Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.
...
llvm-svn: 135040
2011-07-13 10:26:04 +00:00
Rafael Espindola
403256763f
Don't duplicate the work done by a gep into a "bitcast" if the gep has
...
more than one use.
Fixes PR10322.
llvm-svn: 134883
2011-07-11 03:43:47 +00:00
Eli Friedman
35211c6091
Final step of instcombine debuginfo; switch a couple more places over to InsertNewInstWith, and use setDebugLoc for the cases which can't be easily handled by the automated mechanisms.
...
llvm-svn: 132167
2011-05-27 00:19:40 +00:00
Eli Friedman
68aab459ae
Make instcombine O(N) instead of O(N^2) in code where the same simplifiable constant is used many times.
...
Part of rdar://9471075.
llvm-svn: 131979
2011-05-24 18:52:07 +00:00
Eli Friedman
41e509a33d
More instcombine cleanup, towards improving debug line info.
...
llvm-svn: 131604
2011-05-18 23:58:37 +00:00
Eli Friedman
96254a0d53
Start trying to make InstCombine preserve more debug info. The idea here is to set the debug location on the IRBuilder, which will be then right location in most cases. This should magically give many transformations debug locations, and fixing places which are missing a debug location will usually just means changing the code creating it to use the IRBuilder.
...
As an example, the change to InstCombineCalls catches a common case where a call to a bitcast of a function is rewritten.
Chris, does this approach look reasonable?
llvm-svn: 131516
2011-05-18 01:28:27 +00:00
Eli Friedman
b9ed18f2cb
Use ReplaceInstUsesWith instead of replaceAllUsesWith where appropriate in instcombine.
...
llvm-svn: 131512
2011-05-18 00:32:01 +00:00
Duncan Sands
085ad3b81a
Stop trying to have instcombine preserve LCSSA form: this was not
...
effective in avoiding recomputation of LCSSA form; the widespread
use of instsimplify (which looks through phi nodes) means it was
not preserving LCSSA form anyway; and instcombine is no longer
scheduled in the middle of the loop passes so this doesn't matter
anymore.
llvm-svn: 130301
2011-04-27 10:55:12 +00:00
Nadav Rotem
a069c6ce05
InstCombine optimizes gep(bitcast(x)) even when the bitcasts casts away address
...
space info. We crash with an assert in this case. This change checks that the
address space of the bitcasted pointer is the same as the gep ptr.
llvm-svn: 128884
2011-04-05 14:29:52 +00:00
Jay Foad
52131344a2
Remove PHINode::reserveOperandSpace(). Instead, add a parameter to
...
PHINode::Create() giving the (known or expected) number of operands.
llvm-svn: 128537
2011-03-30 11:28:46 +00:00
Jay Foad
1c83965f5a
Make more use of PHINode::getNumIncomingValues().
...
llvm-svn: 128406
2011-03-28 13:03:10 +00:00
Devang Patel
aad34d882d
Try to not lose variable's debug info during instcombine.
...
This is done by lowering dbg.declare intrinsic into dbg.value intrinsic.
Radar 9143931.
llvm-svn: 127834
2011-03-17 22:18:16 +00:00
Devang Patel
8d53ac81ec
Do not forget DebugLoc!
...
llvm-svn: 125547
2011-02-15 02:02:30 +00:00
Dan Gohman
c6f0bda839
Conservatively, clear optional flags, such as nsw, when performing
...
reassociation. No testcase, because I wasn't able to create a testcase
which actually demonstrates a problem.
llvm-svn: 124713
2011-02-02 02:05:46 +00:00
Chris Lattner
b5e15d1907
fix PR9013, an infinite loop in instcombine.
...
llvm-svn: 123968
2011-01-21 05:29:50 +00:00
Chris Lattner
f4ca47bda8
update obsolete comment.
...
llvm-svn: 123965
2011-01-21 05:08:26 +00:00
Nick Lewycky
6a083cf820
Don't try to pull vector bitcasts that change the number of elements through
...
a select. A vector select is pairwise on each element so we'd need a new
condition with the right number of elements to select on. Fixes PR8994.
llvm-svn: 123963
2011-01-21 02:30:43 +00:00
Chris Lattner
adb1a233b1
remove a dead check, this was needed before we had an explicit veto on uses of phis.
...
llvm-svn: 123569
2011-01-16 05:37:55 +00:00
Chris Lattner
d55581ded8
enhance FoldOpIntoPhi in instcombine to try harder when a phi has
...
multiple uses. In some cases, all the uses are the same operation,
so instcombine can go ahead and promote the phi. In the testcase
this pushes an add out of the loop.
llvm-svn: 123568
2011-01-16 05:28:59 +00:00
Chris Lattner
ea7131a062
remove the AllowAggressive argument to FoldOpIntoPhi. It is forced to false in the
...
first line of the function because it isn't a good idea, even for compares.
llvm-svn: 123566
2011-01-16 05:14:26 +00:00
Chris Lattner
ff2e737714
more cleanups: use the IR builder.
...
llvm-svn: 123565
2011-01-16 05:08:00 +00:00
Chris Lattner
25ce280511
tidy up code.
...
llvm-svn: 123564
2011-01-16 04:37:29 +00:00
Duncan Sands
fbb9ac3cca
Add a generic expansion transform: A op (B op' C) -> (A op B) op' (A op C)
...
if both A op B and A op C simplify. This fires fairly often but doesn't
make that much difference. On gcc-as-one-file it removes two "and"s and
turns one branch into a select.
llvm-svn: 122399
2010-12-22 13:36:08 +00:00
Duncan Sands
3547d2ebd8
Add some statistics, good for understanding how much more powerful
...
instcombine is compared to instsimplify.
llvm-svn: 122397
2010-12-22 09:40:51 +00:00
Chris Lattner
4fb9dd4c74
fix an oversight caught by Frits!
...
llvm-svn: 122204
2010-12-19 23:24:04 +00:00
Chris Lattner
3e635d2e99
move a transformation to a more logical place, simplifying it.
...
llvm-svn: 122183
2010-12-19 19:43:52 +00:00
Frits van Bommel
28218aa8f1
Transform (extractvalue (load P), ...) to (load (gep P, 0, ...)) if the load has no other uses, shrinking the load.
...
llvm-svn: 120323
2010-11-29 21:56:20 +00:00