Eli Friedman
41e509a33d
More instcombine cleanup, towards improving debug line info.
...
llvm-svn: 131604
2011-05-18 23:58:37 +00:00
Eli Friedman
2395626605
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
Benjamin Kramer
68531baea9
Teach InstCombine to merge (icmp ult (X + CA), C1) | (icmp eq X, C2) into (icmp ult (X + CA), C1 + 1) if C2 + CA == C1.
...
InstCombine creates these so now we compile x == 23 || x == 24 || x == 25 to
%x.off = add i32 %x, -23
%1 = icmp ult i32 %x.off, 3
instead of
%x.off = add i32 %x, -23
%1 = icmp ult i32 %x.off, 2
%cmp3 = icmp eq i32 %x, 25
%ret2 = or i1 %1, %cmp3
llvm-svn: 122248
2010-12-20 16:18:51 +00:00
Owen Anderson
c237a849e3
Re-apply r113679, which was reverted in r113720, which added a paid of new instcombine transforms
...
to expose greater opportunities for store narrowing in codegen. This patch fixes a potential
infinite loop in instcombine caused by one of the introduced transforms being overly aggressive.
llvm-svn: 113763
2010-09-13 17:59:27 +00:00
Eric Christopher
26abd3e0c2
Revert 113679, it was causing an infinite loop in a testcase that I've sent
...
on to Owen.
llvm-svn: 113720
2010-09-12 06:09:23 +00:00
Owen Anderson
70f4524427
Invert and-of-or into or-of-and when doing so would allow us to clear bits of the and's mask.
...
This can result in increased opportunities for store narrowing in code generation. Update a number of
tests for this change. This fixes <rdar://problem/8285027>.
Additionally, because this inverts the order of ors and ands, some patterns for optimizing or-of-and-of-or
no longer fire in instances where they did originally. Add a simple transform which recaptures most of these
opportunities: if we have an or-of-constant-or and have failed to fold away the inner or, commute the order
of the two ors, to give the non-constant or a chance for simplification instead.
llvm-svn: 113679
2010-09-11 05:48:06 +00:00
Benjamin Kramer
8c35fb0739
Teach InstructionSimplify to fold (A & B) & A -> A & B and (A | B) | A -> A | B.
...
Reassociate does this but it doesn't catch all cases (e.g. if the operands are i1).
llvm-svn: 113651
2010-09-10 22:39:55 +00:00
Chris Lattner
ec0e7b1643
revert r108320, I see the failures now...
...
llvm-svn: 108322
2010-07-14 06:16:35 +00:00
Chris Lattner
658680b2f5
reapply benjamin's instcombine patch, I don't see anything wrong with it and can't repro any problems with a manual self-host.
...
llvm-svn: 108320
2010-07-14 05:59:13 +00:00
Benjamin Kramer
8f36402ac2
Nope, still breaks the release selfhost bots :(
...
llvm-svn: 108153
2010-07-12 16:38:48 +00:00
Benjamin Kramer
07b695e052
Reapply the "or" half of r108136, which seems to be less problematic.
...
llvm-svn: 108152
2010-07-12 16:15:48 +00:00
Benjamin Kramer
c719e8ae9e
Revert r108141 again, sigh.
...
llvm-svn: 108148
2010-07-12 14:42:04 +00:00
Benjamin Kramer
f578c36035
Reapply 108136 with an ugly pasto fixed.
...
llvm-svn: 108141
2010-07-12 13:44:00 +00:00
Benjamin Kramer
9675e759cf
Revert r108136 until I figure out why it broke selfhost.
...
llvm-svn: 108139
2010-07-12 12:35:49 +00:00
Benjamin Kramer
35473faa50
instcombine: fold (x & y) | (~x & z) and (x & y) ^ (~x & z) into ((y ^ z) & x) ^ z which is one instruction shorter. (PR6773)
...
before:
%and = and i32 %y, %x
%neg = xor i32 %x, -1
%and4 = and i32 %z, %neg
%xor = xor i32 %and4, %and
after:
%xor1 = xor i32 %z, %y
%and2 = and i32 %xor1, %x
%xor = xor i32 %and2, %z
llvm-svn: 108136
2010-07-12 11:54:45 +00:00
Chris Lattner
fc13a0343c
make these less sensitive to temporary naming.
...
llvm-svn: 97799
2010-03-05 08:43:33 +00:00
Chris Lattner
8e2c471614
don't turn (A & (C0?-1:0)) | (B & ~(C0?-1:0)) -> C0 ? A : B
...
for vectors. Codegen is generating awful code or segfaulting
in various cases (e.g. PR6204).
llvm-svn: 95058
2010-02-02 02:43:51 +00:00
Chris Lattner
9518869423
add one more bitfield optimization, allowing clang to generate
...
good code on PR4216:
_test_bitfield: ## @test_bitfield
orl $32962, %edi
movl $4294941946, %eax
andq %rdi, %rax
ret
instead of:
_test_bitfield:
movl $4294941696, %ecx
movl %edi, %eax
orl $194, %edi
orl $32768, %eax
andq $250, %rdi
andq %rax, %rcx
movq %rdi, %rax
orq %rcx, %rax
ret
Evan is looking into the remaining andq+imm -> andl optimization.
llvm-svn: 93147
2010-01-11 06:55:24 +00:00
Chris Lattner
2d91231d82
implement an instcombine xform needed by clang's codegen
...
on the example in PR4216. This doesn't trigger in the testsuite,
so I'd really appreciate someone scrutinizing the logic for
correctness.
llvm-svn: 92458
2010-01-04 06:03:59 +00:00
Nick Lewycky
a67519be12
Fix logic error in previous commit. The != case needs to become an or, not an
...
and.
llvm-svn: 92419
2010-01-02 16:14:56 +00:00
Nick Lewycky
357d41b3c1
Optimize pointer comparison into the typesafe form, now that the backends will
...
handle them efficiently. This is the opposite direction of the transformation
we used to have here.
llvm-svn: 92418
2010-01-02 15:25:44 +00:00
Chris Lattner
2e4be2c340
remove the instcombine transformations that are inserting nasty
...
pointer to int casts that confuse later optimizations. See PR3351
for details.
This improves but doesn't complete fix 483.xalancbmk because llvm-gcc
does this xform in GCC's "fold" routine as well. Clang++ will do
better I guess.
llvm-svn: 92408
2010-01-02 00:31:05 +00:00
Chris Lattner
cd261c9c26
Implement PR5634.
...
llvm-svn: 90046
2009-11-29 00:51:17 +00:00
Chris Lattner
683eed3286
reapply r85085 with a bugfix to avoid infinite looping.
...
All of the 'demorgan' related xforms need to use
dyn_castNotVal, not m_Not.
llvm-svn: 85119
2009-10-26 15:40:07 +00:00
Evan Cheng
8014a728b9
Revert 85085. It causes infinite looping during llvm-gcc build.
...
llvm-svn: 85090
2009-10-26 03:51:32 +00:00
Chris Lattner
2e6564d6ff
Implement PR3266 & PR5276, folding:
...
not (or (icmp, icmp)) -> and(icmp, icmp)
llvm-svn: 85085
2009-10-26 01:06:31 +00:00
Chris Lattner
52880b29d2
convert or.ll to filecheck and merge or2 into it.
...
llvm-svn: 85083
2009-10-25 23:47:55 +00:00
Dan Gohman
1880092722
Change tests from "opt %s" to "opt < %s" so that opt doesn't see the
...
input filename so that opt doesn't print the input filename in the
output so that grep lines in the tests don't unintentionally match
strings in the input filename.
llvm-svn: 81537
2009-09-11 18:01:28 +00:00
Dan Gohman
72a13d2476
Use opt -S instead of piping bitcode output through llvm-dis.
...
llvm-svn: 81257
2009-09-08 22:34:10 +00:00
Dan Gohman
9737a63ed8
Change these tests to feed the assembly files to opt directly, instead
...
of using llvm-as, now that opt supports this.
llvm-svn: 81226
2009-09-08 16:50:01 +00:00
Tanya Lattner
5640bd186a
Remove llvm-upgrade and update test cases.
...
llvm-svn: 47793
2008-03-01 09:15:35 +00:00
Reid Spencer
ede8c3b92c
For PR1319:
...
Make use of the END. facility on all files > 1K so that we aren't wasting CPU
cycles searching for RUN: lines that we'll never find.
llvm-svn: 36059
2007-04-15 07:38:21 +00:00
Reid Spencer
91948d4cad
For PR1319:
...
Upgrade tests to work with new llvm.exp version of llvm_runtest.
llvm-svn: 36013
2007-04-14 20:13:02 +00:00
Reid Spencer
83b3d82672
Regression is gone, don't try to find it on clean target.
...
llvm-svn: 33296
2007-01-17 07:59:14 +00:00