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
11522097be
Remove some support for ReturnInsts with multiple operands, and for
...
returning a scalar value in a function whose return type is a single-
element structure or array.
llvm-svn: 128810
2011-04-04 07:44:02 +00:00
Eli Friedman
b85c0caf7d
Attempt to fix breakage from r128782 reported by Francois Pichet on
...
llvm-commits. (Not sure why it only breaks on Windows; maybe it has
something to do with the iterator representation...)
llvm-svn: 128802
2011-04-04 00:37:38 +00:00
Eli Friedman
17bf4922c9
PR9446: RecursivelyDeleteTriviallyDeadInstructions can delete the instruction
...
after the given instruction; make sure to handle that case correctly.
(It's difficult to trigger; the included testcase involves a dead
block, but I don't think that's a requirement.)
While I'm here, get rid of the unnecessary warning about
SimplifyInstructionsInBlock, since it should work correctly as far as I know.
llvm-svn: 128782
2011-04-02 22:45:17 +00:00
Benjamin Kramer
50a281a871
While SimplifyDemandedBits constant folds this, we can't rely on it here.
...
It's possible to craft an input that hits the recursion limits in a way
that SimplifyDemandedBits doesn't simplify the icmp but ComputeMaskedBits
can infer which bits are zero.
No test case as it depends on too many other things. Fixes PR9609.
llvm-svn: 128777
2011-04-02 18:50:58 +00:00
Benjamin Kramer
8b94c295c3
Fix comment.
...
llvm-svn: 128745
2011-04-01 22:29:18 +00:00
Benjamin Kramer
5cad45307e
Tweaks to the icmp+sext-to-shifts optimization to address Frits' comments:
...
- Localize the check if an icmp has one use to a place where we know we're
introducing something that's likely more expensive than a sext from i1.
- Add an assert to make sure a case that would lead to a miscompilation is
folded away earlier.
- Fix a typo.
llvm-svn: 128744
2011-04-01 22:22:11 +00:00
Benjamin Kramer
ac2d5657a6
Fix build.
...
llvm-svn: 128733
2011-04-01 20:15:16 +00:00
Benjamin Kramer
d121765e64
InstCombine: Turn icmp + sext into bitwise/integer ops when the input has only one unknown bit.
...
int test1(unsigned x) { return (x&8) ? 0 : -1; }
int test3(unsigned x) { return (x&8) ? -1 : 0; }
before (x86_64):
_test1:
andl $8, %edi
cmpl $1, %edi
sbbl %eax, %eax
ret
_test3:
andl $8, %edi
cmpl $1, %edi
sbbl %eax, %eax
notl %eax
ret
after:
_test1:
shrl $3, %edi
andl $1, %edi
leal -1(%rdi), %eax
ret
_test3:
shll $28, %edi
movl %edi, %eax
sarl $31, %eax
ret
llvm-svn: 128732
2011-04-01 20:09:10 +00:00
Benjamin Kramer
398b8c5faf
InstCombine: Move (sext icmp) transforms into their own method. No intended functionality change.
...
llvm-svn: 128731
2011-04-01 20:09:03 +00:00
Nadav Rotem
d74b72b8a9
Instcombile optimization: extractelement(cast) -> cast(extractelement)
...
llvm-svn: 128683
2011-03-31 22:57:29 +00:00
Benjamin Kramer
5291054ef1
InstCombine: APFloat can't perform arithmetic on PPC double doubles, don't even try.
...
Thanks Eli!
llvm-svn: 128676
2011-03-31 21:35:49 +00:00
Benjamin Kramer
be209ab8a2
InstCombine: Fix transform to use the swapped predicate.
...
Thanks Frits!
llvm-svn: 128628
2011-03-31 10:46:03 +00:00
Benjamin Kramer
d159d94644
InstCombine: fold fcmp (fneg x), (fneg y) -> fcmp x, y
...
llvm-svn: 128627
2011-03-31 10:12:22 +00:00
Benjamin Kramer
a8c5d0872d
InstCombine: fold fcmp pred (fneg x), C -> fcmp swap(pred) x, -C
...
llvm-svn: 128626
2011-03-31 10:12:15 +00:00
Benjamin Kramer
cbb18e91a8
InstCombine: Shrink "fcmp (fpext x), C" to "fcmp x, C" if C can be losslessly converted to the type of x.
...
Fixes PR9592.
llvm-svn: 128625
2011-03-31 10:12:07 +00:00
Benjamin Kramer
2ccfbc8b71
InstCombine: fold fcmp (fpext x), (fpext y) -> fcmp x, y.
...
llvm-svn: 128624
2011-03-31 10:11:58 +00:00
Bill Wendling
5034159c5f
* The DSE code that tested for overlapping needed to take into account the fact
...
that one of the numbers is signed while the other is unsigned. This could lead
to a wrong result when the signed was promoted to an unsigned int.
* Add the data layout line to the testcase so that it will test the appropriate
thing.
Patch by David Terei!
llvm-svn: 128577
2011-03-30 21:37:19 +00:00
Benjamin Kramer
8564e0de96
InstCombine: If the divisor of an fdiv has an exact inverse, turn it into an fmul.
...
Fixes PR9587.
llvm-svn: 128546
2011-03-30 15:42:35 +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
e0938d8a87
(Almost) always call reserveOperandSpace() on newly created PHINodes.
...
llvm-svn: 128535
2011-03-30 11:19:20 +00:00
Benjamin Kramer
272f2b0044
InstCombine: Add a few missing combines for ANDs and ORs of sign bit tests.
...
On x86 we now compile "if (a < 0 && b < 0)" into
testl %edi, %esi
js IF.THEN
llvm-svn: 128496
2011-03-29 22:06:41 +00:00
Benjamin Kramer
e41395ac24
DSE: Remove an early exit optimization that depended on the ordering of a SmallPtrSet.
...
Fixes PR9569 and will hopefully make selfhost on ASLR-enabled systems more deterministic.
llvm-svn: 128482
2011-03-29 20:28:57 +00:00
Cameron Zwarich
ff811cc475
Do some simple copy propagation through integer loads and stores when promoting
...
vector types. This helps a lot with inlined functions when using the ARM soft
float ABI. Fixes <rdar://problem/9184212>.
llvm-svn: 128453
2011-03-29 05:19:52 +00:00
Nick Lewycky
ebc2f3a68c
Remove tabs I accidentally added.
...
llvm-svn: 128413
2011-03-28 17:48:26 +00:00
Jay Foad
1c83965f5a
Make more use of PHINode::getNumIncomingValues().
...
llvm-svn: 128406
2011-03-28 13:03:10 +00:00
Frits van Bommel
d14d991bf7
Add some debug output when -instcombine uses RAUW. This can make debug output for those cases much clearer since without this it only showed that the original instruction was removed, not what it was replaced with.
...
llvm-svn: 128399
2011-03-27 23:32:31 +00:00
Nick Lewycky
8544228d5a
Teach the transformation that moves binary operators around selects to preserve
...
the subclass optional data.
llvm-svn: 128388
2011-03-27 19:51:23 +00:00
Benjamin Kramer
1f90da127f
Use APInt's umul_ov instead of rolling our own overflow detection.
...
llvm-svn: 128380
2011-03-27 15:04:38 +00:00
Nick Lewycky
83167df787
Add a small missed optimization: turn X == C ? X : Y into X == C ? C : Y. This
...
removes one use of X which helps it pass the many hasOneUse() checks.
In my analysis, this turns up very often where X = A >>exact B and that can't be
simplified unless X has one use (except by increasing the lifetime of A which is
generally a performance loss).
llvm-svn: 128373
2011-03-27 07:30:57 +00:00
Bill Wendling
b5139920d6
Simplification noticed by Frits.
...
llvm-svn: 128333
2011-03-26 09:32:07 +00:00
Bill Wendling
19f33b9393
Rework the logic that determines if a store completely overlaps an ealier store.
...
There are two ways that a later store can comletely overlap a previous store:
1. They both start at the same offset, but the earlier store's size is <= the
later's size, or
2. The earlier store's offset is > the later's offset, but it's offset + size
doesn't extend past the later's offset + size.
llvm-svn: 128332
2011-03-26 08:02:59 +00:00
Cameron Zwarich
d4174ee43e
Fix a typo and add a test.
...
llvm-svn: 128331
2011-03-26 04:58:50 +00:00
Bill Wendling
db40b5c899
PR9561: A store with a negative offset (via GEP) could erroniously say that it
...
completely overlaps a previous store, thus mistakenly deleting that store. Check
for this condition.
llvm-svn: 128319
2011-03-26 01:20:37 +00:00
Nick Lewycky
0e25c8b364
No functionality change, just adjust some whitespace for coding style compliance.
...
llvm-svn: 128257
2011-03-25 06:05:50 +00:00
Cameron Zwarich
74157ab3e5
Debug intrinsics must be skipped at the beginning and ends of blocks, lest they
...
affect the generated code.
llvm-svn: 128217
2011-03-24 16:34:59 +00:00
Cameron Zwarich
2edfe778ec
It is enough for the CallInst to have no uses to be made a tail call with a ret
...
void; it doesn't need to have a void type.
llvm-svn: 128212
2011-03-24 15:54:11 +00:00
Devang Patel
8f606d7b9b
s/UpdateDT/ModifiedDT/g
...
llvm-svn: 128211
2011-03-24 15:35:25 +00:00
Cameron Zwarich
4649f17db1
Do early taildup of ret in CodeGenPrepare for potential tail calls that have a
...
void return type. This fixes PR9487.
llvm-svn: 128197
2011-03-24 04:52:10 +00:00
Cameron Zwarich
0e331c05ae
Use an early return instead of a long if block.
...
llvm-svn: 128196
2011-03-24 04:52:07 +00:00
Cameron Zwarich
dd84bcce8f
When UpdateDT is set, DT is invalid, which could cause problems when trying to
...
use it later. I couldn't make a test that hits this with the current code.
llvm-svn: 128195
2011-03-24 04:52:04 +00:00
Cameron Zwarich
47e7175fe9
Check for TLI so that -codegenprepare can be used from opt.
...
llvm-svn: 128194
2011-03-24 04:51:51 +00:00
Cameron Zwarich
10ebc189ee
Fix PR9464 by correcting some math that just happened to be right in most cases
...
that were hit in practice.
llvm-svn: 128146
2011-03-23 05:25:55 +00:00
Anders Carlsson
1cc8073bb3
Handle another case that Frits suggested.
...
llvm-svn: 128068
2011-03-22 03:21:01 +00:00
Devang Patel
17bbd7f495
Simplify.
...
llvm-svn: 128030
2011-03-21 22:04:45 +00:00
Anders Carlsson
4dd420f193
More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function.
...
llvm-svn: 127997
2011-03-21 14:54:40 +00:00
Anders Carlsson
701822a48e
As suggested by Nick Lewycky, ignore debugging intrinsics when trying to decide whether a destructor is empty or not.
...
llvm-svn: 127985
2011-03-21 02:42:27 +00:00
Nick Lewycky
d078183725
Fix comments
...
llvm-svn: 127984
2011-03-21 02:26:01 +00:00
Evan Cheng
0663f23bd8
Re-apply r127953 with fixes: eliminate empty return block if it has no predecessors; update dominator tree if cfg is modified.
...
llvm-svn: 127981
2011-03-21 01:19:09 +00:00
Anders Carlsson
336fd90f4d
Don't try to eliminate invokes to __cxa_atexit.
...
llvm-svn: 127976
2011-03-20 20:21:33 +00:00