Bill Wendling
0506959970
Use Duncan's patch to delete the instructions in reverse order (minus the landingpad and terminator).
...
llvm-svn: 139090
2011-09-04 09:43:36 +00:00
Bill Wendling
3033d7846d
Update comments to reflect reality.
...
llvm-svn: 139023
2011-09-02 18:43:33 +00:00
Bill Wendling
b6a419d0f0
Reduce indentation. No functionality change.
...
llvm-svn: 138968
2011-09-01 21:29:49 +00:00
Bill Wendling
759eb19f0b
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
a6d17107f5
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
d984ff9663
Submitted this too early.
...
llvm-svn: 138931
2011-09-01 01:18:33 +00:00
Bill Wendling
37fc90ccd9
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
3566980062
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
3d7b8eaa78
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
3016a47ed2
Don't sink the instruction to before a landingpad instruction.
...
llvm-svn: 137672
2011-08-15 22:53:05 +00:00
Eli Friedman
36ef5fd140
Update instcombine for atomic load/store.
...
llvm-svn: 137664
2011-08-15 22:09:40 +00:00
Bill Wendling
a75d2d0416
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
a8d6570a7a
Don't try to sink the landingpad instruction. It's immobile.
...
llvm-svn: 137629
2011-08-15 18:23:40 +00:00
Nick Lewycky
e020632f7e
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
0326303a7a
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
b6a9488190
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
16af9d24c5
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
82418c24b8
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
05fed81aa9
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
92b7e5d6e5
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
6513dac6e2
Convert GetElementPtrInst to use ArrayRef.
...
llvm-svn: 135904
2011-07-25 09:48:08 +00:00
Jay Foad
42463ed852
Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to use
...
ArrayRef.
llvm-svn: 135761
2011-07-22 08:16:57 +00:00
Jay Foad
bbbf29aab7
Convert SimplifyGEPInst to use ArrayRef.
...
llvm-svn: 135482
2011-07-19 15:07:52 +00:00
Frits van Bommel
6c24f9c277
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
e1fe7061ce
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
88fb4f4597
Convert InsertValueInst and ExtractValueInst APIs to use ArrayRef.
...
llvm-svn: 135040
2011-07-13 10:26:04 +00:00
Rafael Espindola
b42084315a
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
6937c422a0
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
5ae1b40f55
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
40a0353b96
More instcombine cleanup, towards improving debug line info.
...
llvm-svn: 131604
2011-05-18 23:58:37 +00:00
Eli Friedman
5d2823e452
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
358d9a5af3
Use ReplaceInstUsesWith instead of replaceAllUsesWith where appropriate in instcombine.
...
llvm-svn: 131512
2011-05-18 00:32:01 +00:00
Duncan Sands
4c4f3dbea6
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
8bb81fc184
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
53632b7c03
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
bfb0312e40
Make more use of PHINode::getNumIncomingValues().
...
llvm-svn: 128406
2011-03-28 13:03:10 +00:00
Devang Patel
f8c3eb7368
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
091c6a8907
Do not forget DebugLoc!
...
llvm-svn: 125547
2011-02-15 02:02:30 +00:00
Dan Gohman
11acb5002d
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
f225708ef1
fix PR9013, an infinite loop in instcombine.
...
llvm-svn: 123968
2011-01-21 05:29:50 +00:00
Chris Lattner
9a4cefc8ee
update obsolete comment.
...
llvm-svn: 123965
2011-01-21 05:08:26 +00:00
Nick Lewycky
c4300debc2
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
1a125a870f
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
2067fb2a93
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
84d8f40fbb
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
c639cb2c82
more cleanups: use the IR builder.
...
llvm-svn: 123565
2011-01-16 05:08:00 +00:00
Chris Lattner
9af2484c39
tidy up code.
...
llvm-svn: 123564
2011-01-16 04:37:29 +00:00
Duncan Sands
922251757b
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
9b28a173fe
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
c8327b2f7c
fix an oversight caught by Frits!
...
llvm-svn: 122204
2010-12-19 23:24:04 +00:00