Chris Lattner
2e2fad280a
Stop accepting and ignoring attributes in function types. Attributes are applied
...
to functions and call/invokes, not to types.
llvm-svn: 133266
2011-06-17 17:37:13 +00:00
Chris Lattner
0899957b99
make the asmparser reject function and type redefinitions. 'Merging' hasn't been
...
needed since llvm-gcc 3.4 days.
llvm-svn: 133248
2011-06-17 07:06:44 +00:00
Chris Lattner
9e7c036d09
remove parser support for the obsolete "multiple return values" syntax, which
...
was replaced with return of a "first class aggregate".
llvm-svn: 133245
2011-06-17 06:49:41 +00:00
Chris Lattner
4eb6f76fa6
Remove support for using "foo" as symbols instead of %"foo". This is ancient
...
syntax and has been long obsolete. As usual, updating the tests is the nasty
part of this.
llvm-svn: 133242
2011-06-17 06:36:20 +00:00
Chris Lattner
9ec82f54d4
manually upgrade a bunch of tests to modern syntax, and remove some that
...
are either unreduced or only test old syntax.
llvm-svn: 133228
2011-06-17 03:14:27 +00:00
Stuart Hastings
65d0bc94b4
Avoid fusing bitcasts with dynamic allocas if the amount-to-allocate
...
might overflow. Re-typing the alloca to a larger type (e.g. double)
hoists a shift into the alloca, potentially exposing overflow in the
expression. rdar://problem/9265821
llvm-svn: 132926
2011-06-13 18:48:49 +00:00
Benjamin Kramer
5079b61657
InstCombine: Fold A-b == C --> b == A-C if A and C are constants.
...
The backend already knew this trick.
llvm-svn: 132915
2011-06-13 15:24:24 +00:00
Benjamin Kramer
b0765d6ac0
InstCombine: Shrink ((zext X) & C1) == C2 to fold away the cast if the "zext" and the "and" have one use.
...
llvm-svn: 132897
2011-06-12 22:48:00 +00:00
Benjamin Kramer
4a0f846bbd
Simplify code. No functionality changes, name changes aside.
...
llvm-svn: 132896
2011-06-12 22:47:53 +00:00
Stuart Hastings
904f5d9bd7
Reapply 132348 with fixes. rdar://problem/6501862
...
llvm-svn: 132402
2011-06-01 16:42:47 +00:00
Stuart Hastings
47cbd200e4
Revert to pacify a buildbot. rdar://problem/6501862
...
llvm-svn: 132351
2011-05-31 19:56:35 +00:00
Stuart Hastings
e226ec461c
Followup to 132316; accept arbitrary constants, add with a constant,
...
sub with a non-constant. Fix comments, enlarge test case.
rdar://problem/6501862
llvm-svn: 132348
2011-05-31 19:29:55 +00:00
Stuart Hastings
9f37a92c33
(1 - X) * (-2) -> (x - 1) * 2, for all positive nonzero powers of 2
...
rdar://problem/6501862
llvm-svn: 132316
2011-05-30 20:00:33 +00:00
Benjamin Kramer
129192d295
ConstantFoldInstOperands doesn't like compares, hand it off to instsimplify instead.
...
Fixes PR10040.
llvm-svn: 132254
2011-05-28 10:16:58 +00:00
Benjamin Kramer
5b491b9d0e
InstCombine: Make switch folding with equality compares more aggressive by trying instsimplify on the arm where we know the compared value.
...
Stuff like "x == y ? y : x&y" now folds into "x&y".
llvm-svn: 132185
2011-05-27 13:00:16 +00:00
Chad Rosier
b87c4a6945
Renamed llvm.x86.sse42.crc32 intrinsics; crc64 doesn't exist.
...
crc32.[8|16|32] have been renamed to .crc32.32.[8|16|32] and
crc64.[8|16|32] have been renamed to .crc32.64.[8|64].
llvm-svn: 132163
2011-05-26 23:13:19 +00:00
Eli Friedman
5cd755549b
PR9998: ashr exact %x, 31 is not equivalent to sdiv exact %x, -2147483648.
...
llvm-svn: 132097
2011-05-25 23:26:20 +00:00
Chris Lattner
ec35f49b3e
Transform any logical shift of a power of two into an exact/NUW shift when
...
in a known-non-zero context.
llvm-svn: 131887
2011-05-23 00:21:50 +00:00
Chris Lattner
8ed794f599
Carve out a place in instcombine to put transformations which work knowing that their
...
result is non-zero. Implement an example optimization (PR9814), which allows us to
transform:
A / ((1 << B) >>u 2)
into:
A >>u (B-2)
which we compile into:
_divu3: ## @divu3
leal -2(%rsi), %ecx
shrl %cl, %edi
movl %edi, %eax
ret
instead of:
_divu3: ## @divu3
movb %sil, %cl
movl $1, %esi
shll %cl, %esi
shrl $2, %esi
movl %edi, %eax
xorl %edx, %edx
divl %esi, %eax
ret
llvm-svn: 131860
2011-05-22 18:18:41 +00:00
Benjamin Kramer
24f75ab769
Revert "InstCombine: Turn mul.with.overflow(X, 2) into the cheaper add.with.overflow(X, X)"
...
It's better to do this in codegen, mul.with.overflow(X, 2) is more canonical because it has only one use on "X".
llvm-svn: 131798
2011-05-21 18:31:42 +00:00
Benjamin Kramer
51d1eac4bc
InstCombine: Turn mul.with.overflow(X, 2) into the cheaper add.with.overflow(X, X)
...
llvm-svn: 131789
2011-05-21 09:22:06 +00:00
Evan Cheng
a3f5204c82
Revert r131664 and fix it in instcombine instead. rdar://9467055
...
llvm-svn: 131708
2011-05-20 00:54:37 +00:00
Stuart Hastings
b524e73afc
Move test to Transforms/InstCombine.
...
llvm-svn: 131634
2011-05-19 05:53:22 +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
889faa7ead
More instcombine cleanup aimed towards improving debug line info.
...
llvm-svn: 131559
2011-05-18 19:57:14 +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
Stuart Hastings
d3595bfb53
Drop lli, revise test.
...
llvm-svn: 131452
2011-05-17 02:38:59 +00:00
Benjamin Kramer
f619bee58f
Disable test harder.
...
llvm-svn: 131363
2011-05-14 19:30:39 +00:00
Stuart Hastings
a5b8581bbb
Disable this test while I revise it. rdar://problem/9267970
...
llvm-svn: 131350
2011-05-14 18:39:05 +00:00
Stuart Hastings
725bd9a3a1
Avoid combining GEPs that might overflow at runtime.
...
rdar://problem/9267970
Patch by Julien Lerouge!
llvm-svn: 131339
2011-05-14 05:55:10 +00:00
Eli Friedman
c562cbdb82
PR9838: Fix transform introduced in r127064 to not trigger when only one side of the icmp is an exact shift.
...
llvm-svn: 130954
2011-05-05 21:59:18 +00:00
Duncan Sands
8c729e71c2
Fix PR9579: when simplifying a compare to "true" or "false", and it was
...
a vector compare, generate a vector result rather than i1 (and crashing).
llvm-svn: 130706
2011-05-02 18:51:41 +00:00
Benjamin Kramer
e4853baa4b
InstCombine: Turn (zext A) udiv (zext B) into (zext (A udiv B)). Same for urem or constant B.
...
This obviously helps a lot if the division would be turned into a libcall
(think i64 udiv on i386), but div is also one of the few remaining instructions
on modern CPUs that become more expensive when the bitwidth gets bigger.
This also helps register pressure on i386 when dividing chars, divb needs
two 8-bit parts of a 16 bit register as input where divl uses two registers.
int foo(unsigned char a) { return a/10; }
int bar(unsigned char a, unsigned char b) { return a/b; }
compiles into (x86_64)
_foo:
imull $205, %edi, %eax
shrl $11, %eax
ret
_bar:
movzbl %dil, %eax
divb %sil, %al
movzbl %al, %eax
ret
llvm-svn: 130615
2011-04-30 18:16:07 +00:00
Benjamin Kramer
5459f78745
Use SimplifyDemandedBits on div instructions.
...
This folds away silly stuff like (a&255)/1000 -> 0.
llvm-svn: 130614
2011-04-30 18:16:00 +00:00
Benjamin Kramer
eeda6d1bb5
FileCheckize.
...
llvm-svn: 130613
2011-04-30 18:15:53 +00:00
Benjamin Kramer
5beaa1dd92
InstCombine: turn (C1 << A) << C2) into (C1 << C2) << A)
...
Fixes PR9809.
llvm-svn: 130485
2011-04-29 08:15:41 +00:00
Benjamin Kramer
4790d699e0
InstCombine: Merge "(trunc x) == C1 & (and x, CA) == C2" into a single and+icmp.
...
This happens when GVN widens loads. Part of PR6627.
llvm-svn: 130405
2011-04-28 16:58:40 +00:00
Chris Lattner
01ceb99a05
Transform: "icmp eq (trunc (lshr(X, cst1)), cst" to "icmp (and X, mask), cst"
...
when X has multiple uses. This is useful for exposing secondary optimizations,
but the X86 backend isn't ready for this when X has a single use. For example,
this can disable load folding.
This is inching towards resolving PR6627.
llvm-svn: 130238
2011-04-26 20:18:20 +00:00
Frits van Bommel
978376c200
Add test cases for Jay's r129641 and fix a 32-bit-centric testcase in a file with a 64-bit datalayout.
...
llvm-svn: 129643
2011-04-16 14:31:50 +00:00
Chris Lattner
0304b82f80
Fix a ton of comment typos found by codespell. Patch by
...
Luis Felipe Strano Moraes!
llvm-svn: 129558
2011-04-15 05:18:47 +00:00
Eli Friedman
198c39a4fe
Add an instcombine for constructs like a | -(b != c); a select is more
...
canonical, and generally leads to better code. Found while looking at
an article about saturating arithmetic.
llvm-svn: 129545
2011-04-14 22:41:27 +00:00
Nadav Rotem
ecc7d9a408
This testcase passed even without the fix. Added the target info to make the
...
test fail (without the fix). Thanks Dan.
llvm-svn: 128999
2011-04-06 11:18:29 +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
Benjamin Kramer
7c0178b9ec
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
Nadav Rotem
897b838d5f
Instcombile optimization: extractelement(cast) -> cast(extractelement)
...
llvm-svn: 128683
2011-03-31 22:57:29 +00:00
Benjamin Kramer
22bdd799ee
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
40e705fb80
InstCombine: Fix transform to use the swapped predicate.
...
Thanks Frits!
llvm-svn: 128628
2011-03-31 10:46:03 +00:00
Benjamin Kramer
40a71a4a85
InstCombine: fold fcmp (fneg x), (fneg y) -> fcmp x, y
...
llvm-svn: 128627
2011-03-31 10:12:22 +00:00
Benjamin Kramer
e16910dd92
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
fd3a92ea15
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