Dan Gohman
6f40163d83
Teach instcombine's visitLoad to scan back several instructions
...
to find opportunities for store-to-load forwarding or load CSE,
in the same way that visitStore scans back to do DSE. Also, define
a new helper function for testing whether the addresses of two
memory accesses are known to have the same value, and use it in
both visitStore and visitLoad.
These two changes allow instcombine to eliminate loads in code
produced by front-ends that frequently emit obviously redundant
addressing for memory references.
llvm-svn: 57608
2008-10-15 23:19:35 +00:00
Evan Cheng
591baeed7c
Combine (fcmp cc0 x, y) | (fcmp cc1 x, y) into a single fcmp when possible.
...
llvm-svn: 57515
2008-10-14 18:44:08 +00:00
Evan Cheng
778b47e6c0
- Somehow I forgot about one / une.
...
- Renumber fcmp predicates to match their icmp counterparts.
- Try swapping operands to expose more optimization opportunities.
llvm-svn: 57513
2008-10-14 18:13:38 +00:00
Evan Cheng
91528965e7
Optimize anding of two fcmp into a single fcmp if the operands are the same. e.g. uno && ueq -> ueq
...
ord && olt -> olt
ord && ueq -> oeq
llvm-svn: 57507
2008-10-14 17:15:11 +00:00
Matthijs Kooijman
b86d48c717
Make InstructionCombining::getBitCastOperand() recognize GEP instructions and
...
constant expression with all zero indices as being the same as a bitcast.
llvm-svn: 57442
2008-10-13 15:17:01 +00:00
Chris Lattner
7a61ef92f5
Fix PR2697 by rewriting the '(X / pos) op neg' logic. This also changes
...
a couple other cases for clarity, but shouldn't affect correctness.
Patch by Eli Friedman!
llvm-svn: 57387
2008-10-11 22:55:00 +00:00
Devang Patel
255fee3bce
Check loop exit predicate properly while eliminating one iteration loop.
...
This patch fixes PR 2869
llvm-svn: 57369
2008-10-10 22:02:57 +00:00
Nuno Lopes
cc4f37aa68
fix memleak by cleaning the global sets on pass exit
...
llvm-svn: 57353
2008-10-10 16:25:50 +00:00
Dale Johannesen
075a62519f
Add a "loses information" return value to APFloat::convert
...
and APFloat::convertToInteger. Restore return value to
IEEE754. Adjust all users accordingly.
llvm-svn: 57329
2008-10-09 23:00:39 +00:00
Nick Lewycky
843c7dfe05
Don't drop alignment on globals when cloning.
...
llvm-svn: 57320
2008-10-09 06:27:14 +00:00
Nuno Lopes
a4813e472c
dont specialize weak functions and the like
...
llvm-svn: 57305
2008-10-08 18:45:59 +00:00
Duncan Sands
8f296a3788
Add <cstdio> include where needed by gcc-4.4.
...
Patch by Samuel Tardieu.
llvm-svn: 57291
2008-10-08 07:23:46 +00:00
Chris Lattner
0aa4423c8c
Add parentheses to avoid warnings in GCC 4.4.0,
...
patch by Samuel Tardieu!
llvm-svn: 57288
2008-10-08 06:42:28 +00:00
Andrew Lenharth
c83731e00a
Correctly set attributes when removing args during cloning. Fixes PR2765
...
llvm-svn: 57254
2008-10-07 18:08:38 +00:00
Devang Patel
378c8633e5
Fix typo, fix PR 2865.
...
llvm-svn: 57221
2008-10-06 23:22:54 +00:00
Matthijs Kooijman
12cd5d041d
Allow scalarrepl to treat an all-zero GEP just as bitcast.
...
This includes not marking a GEP involving a vector as unsafe, but only when it
has all zero indices. This allows scalarrepl to work in a few more cases.
llvm-svn: 57177
2008-10-06 16:23:31 +00:00
Chris Lattner
107e8f8b60
rewrite bswap matching to be more general, allowing arbitrary
...
shifting and masking inside a bswap expr. This allows it to handle
the cases from PR2842, which involve the intermediate 'or'
expressions being shifted, not just the input value.
llvm-svn: 57095
2008-10-05 02:13:19 +00:00
Chris Lattner
6fae76bbf3
fix a bug where the bswap matcher could match a case involving
...
ashr. It should only apply to lshr.
llvm-svn: 57089
2008-10-05 00:50:57 +00:00
Duncan Sands
e22385630e
Ignore loads from and stores to local memory (i.e. allocas)
...
when deciding whether to mark a function readnone/readonly.
Since the pass is currently run before SROA, this may be
quite helpful. Requested by Chris on IRC.
llvm-svn: 57050
2008-10-04 13:24:24 +00:00
Dan Gohman
700611dfc6
Clean up some multiple-return-value code that is no longer
...
applicable.
llvm-svn: 57033
2008-10-03 22:21:24 +00:00
Devang Patel
55401473f9
Nick Lewycky's patch.
...
While hosting instruction check PHI node.
llvm-svn: 57025
2008-10-03 18:57:37 +00:00
Duncan Sands
5edd9b2350
Teach internalize to preserve the callgraph.
...
Why? Because it was there!
llvm-svn: 56996
2008-10-03 07:36:09 +00:00
Owen Anderson
e98ca283b0
SplitBlock should only attempt to update LoopInfo if it is actually being used.
...
llvm-svn: 56994
2008-10-03 06:55:35 +00:00
Duncan Sands
88d8323743
Factorize code: remove variants of "strip off
...
pointer bitcasts and GEP's", and centralize the
logic in Value::getUnderlyingObject. The
difference with stripPointerCasts is that
stripPointerCasts only strips GEPs if all
indices are zero, while getUnderlyingObject
strips GEPs no matter what the indices are.
llvm-svn: 56922
2008-10-01 15:25:41 +00:00
Nuno Lopes
8bf32ebde6
revert the addition of Preverves(CallGraph), per Duncan's comments
...
llvm-svn: 56917
2008-10-01 09:13:40 +00:00
Dan Gohman
b6d0fe7797
Call ScalarEvolution's deleteValueFromRecords before deleting an
...
instruction, not after. This fixes some uses of free'd memory.
llvm-svn: 56908
2008-10-01 02:02:03 +00:00
Nuno Lopes
36e7e0b190
add preserversCFG() + preservers(CallGraph)
...
llvm-svn: 56887
2008-09-30 22:04:30 +00:00
Nuno Lopes
2219758606
add AU.setPreservesCFG() since this pass only adds and removes function attributes
...
llvm-svn: 56868
2008-09-30 18:34:38 +00:00
Nick Lewycky
9e918179c8
Fix misoptimization of: xor i1 (icmp eq (X, C1), icmp s[lg]t (X, C2))
...
llvm-svn: 56834
2008-09-30 06:08:34 +00:00
Duncan Sands
187322048e
Speed up these passes when the callgraph has
...
huge simply connected components. Suggested
by Chris.
llvm-svn: 56787
2008-09-29 14:59:04 +00:00
Nuno Lopes
a4d69747c1
remove redundant test (mayBeOverriden() includes hasLinkOnceLinkage)
...
llvm-svn: 56786
2008-09-29 14:40:32 +00:00
Duncan Sands
60dc0b5cbe
Tweak some comments.
...
llvm-svn: 56784
2008-09-29 13:35:31 +00:00
Duncan Sands
651eeb4be2
Rename isWeakForLinker to mayBeOverridden. Use it
...
instead of hasWeakLinkage in a bunch of optimization
passes.
llvm-svn: 56782
2008-09-29 11:25:42 +00:00
Devang Patel
47a504c87c
Implement function notes as function attributes.
...
llvm-svn: 56716
2008-09-26 23:51:19 +00:00
Devang Patel
e4e6ea0728
Now Attributes are divided in three groups
...
- return attributes - inreg, zext and sext
- parameter attributes
- function attributes - nounwind, readonly, readnone, noreturn
Return attributes use 0 as the index.
Function attributes use ~0U as the index.
This patch requires corresponding changes in llvm-gcc and clang.
llvm-svn: 56704
2008-09-26 22:53:05 +00:00
Devang Patel
64dd7a2e89
Large mechanical patch.
...
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g
This sets the stage
- to implement function notes as function attributes and
- to distinguish between function attributes and return value attributes.
This requires corresponding changes in llvm-gcc and clang.
llvm-svn: 56622
2008-09-25 21:00:45 +00:00
Evan Cheng
99c7d558a5
Commit CodeGenPrepare.cpp changes which was accidentially left out of 56526.
...
llvm-svn: 56549
2008-09-24 06:48:55 +00:00
Eric Christopher
463646c8aa
Fix fallout in CodeGenPrepare from 56526. Will likely need more work.
...
llvm-svn: 56546
2008-09-24 05:32:41 +00:00
Devang Patel
f0bda74eca
s/ParamAttrsWithIndex/FnAttributeWithIndex/g
...
llvm-svn: 56535
2008-09-24 00:55:02 +00:00
Devang Patel
25ecdc49d9
Put FN_NOTE_AlwaysInline and others in FnAttr namespace.
...
llvm-svn: 56527
2008-09-24 00:06:15 +00:00
Devang Patel
b39defd763
Move FN_NOTE_AlwaysInline and other out of ParamAttrs namespace.
...
Do not check isDeclaration() in hasNote(). It is clients' responsibility.
llvm-svn: 56524
2008-09-23 23:52:03 +00:00
Devang Patel
a3e9bf1bca
s/ParameterAttributes/Attributes/g
...
llvm-svn: 56513
2008-09-23 23:03:40 +00:00
Devang Patel
ad8ca34acd
Use parameter attribute store (soon to be renamed) for
...
Function Notes also. Function notes are stored at index ~0.
llvm-svn: 56511
2008-09-23 22:35:17 +00:00
Devang Patel
c7fc5ed65f
Add hasNote() to check note associated with a function.
...
llvm-svn: 56477
2008-09-22 22:32:29 +00:00
Oscar Fuentes
0f25988689
Initial support for the CMake build system.
...
llvm-svn: 56419
2008-09-22 01:08:49 +00:00
Duncan Sands
38b44d2a40
Implement review feedback from Devang: make use
...
of mayReadFromMemory and mayWriteToMemory.
llvm-svn: 56387
2008-09-20 16:45:58 +00:00
Duncan Sands
b2b5ddfaf6
Remove the MarkModRef pass (use AddReadAttrs instead).
...
Unfortunately this means removing one regression test
of GlobalsModRef because I couldn't work out how to
perform it without MarkModRef.
llvm-svn: 56342
2008-09-19 08:23:44 +00:00
Duncan Sands
c2ff9ca568
Add a new pass AddReadAttrs which works out which functions
...
can get the readnone/readonly attributes, and gives them it.
The plan is to remove markmodref (which did the same thing
by querying GlobalsModRef) and delete the analogous
functionality from GlobalsModRef.
llvm-svn: 56341
2008-09-19 08:17:05 +00:00
Devang Patel
1e7ddf5d31
splitLoop does not handle split condition EQ.
...
Fixes PR 2805
llvm-svn: 56321
2008-09-18 23:45:14 +00:00
Bill Wendling
aadf9b22a7
Decrementing the iterator here could be wrong if the worklist is empty after the "erase".
...
Thanks to Ji Young Park for the patch!
llvm-svn: 56316
2008-09-18 23:04:18 +00:00