Bill Wendling
582fe6b0ca
Use m_Specific() instead of double matching.
...
llvm-svn: 60341
2008-12-01 08:09:47 +00:00
Chris Lattner
9e6b243428
simplify these patterns using m_Specific. No need to grep for
...
xor in testcase (or is a substring).
llvm-svn: 60328
2008-12-01 05:16:26 +00:00
Chris Lattner
9d02a70a7d
Teach inst combine to merge GEPs through PHIs. This is really
...
important because it is sinking the loads using the GEPs, but
not the GEPs themselves. This triggers 647 times on 403.gcc
and makes the .s file much much nicer. For example before:
je LBB1_87 ## bb78
LBB1_62: ## bb77
leal 84(%esi), %eax
LBB1_63: ## bb79
movl (%eax), %eax
...
LBB1_87: ## bb78
movl $0, 4(%esp)
movl %esi, (%esp)
call L_make_decl_rtl$stub
jmp LBB1_62 ## bb77
after:
jne LBB1_63 ## bb79
LBB1_62: ## bb78
movl $0, 4(%esp)
movl %esi, (%esp)
call L_make_decl_rtl$stub
LBB1_63: ## bb79
movl 84(%esi), %eax
The input code was (and the GEPs are merged and
the PHI is now eliminated by instcombine):
br i1 %tmp233, label %bb78, label %bb77
bb77:
%tmp234 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22
br label %bb79
bb78:
call void @make_decl_rtl(%struct.tree_node* %t_addr.3, i8* null) nounwind
%tmp235 = getelementptr %struct.tree_node* %t_addr.3, i32 0, i32 0, i32 22
br label %bb79
bb79:
%iftmp.12.0.in = phi %struct.rtx_def** [ %tmp235, %bb78 ], [ %tmp234, %bb77 ]
%iftmp.12.0 = load %struct.rtx_def** %iftmp.12.0.in
llvm-svn: 60322
2008-12-01 02:34:36 +00:00
Bill Wendling
5b902c5b1e
Implement ((A|B)&1)|(B&-2) -> (A&1) | B transformation. This also takes care of
...
permutations of this pattern.
llvm-svn: 60312
2008-12-01 01:07:11 +00:00
Bill Wendling
de89bc275c
Add instruction combining for ((A&~B)|(~A&B)) -> A^B and all permutations.
...
llvm-svn: 60291
2008-11-30 13:52:49 +00:00
Bill Wendling
9eef421e12
Implement (A&((~A)|B)) -> A&B transformation in the instruction combiner. This
...
takes care of all permutations of this pattern.
llvm-svn: 60290
2008-11-30 13:08:13 +00:00
Bill Wendling
2d2e7861b5
getSExtValue() doesn't work for ConstantInts with bitwidth > 64 bits. Use all
...
APInt calls instead.
This fixes PR3144.
llvm-svn: 60288
2008-11-30 12:38:24 +00:00
Bill Wendling
361c0e5f9c
Strengthen check for div inst-combining.
...
llvm-svn: 60276
2008-11-30 04:33:53 +00:00
Bill Wendling
70635adea3
Instcombine was illegally transforming -X/C into X/-C when either X or C
...
overflowed on negation. This commit checks to make sure that neithe C nor X
overflows. This requires that the RHS of X (a subtract instruction) be a
constant integer.
llvm-svn: 60275
2008-11-30 03:42:12 +00:00
Nick Lewycky
4ab50b93c8
Chris prefers icmp/select over udiv!
...
llvm-svn: 60187
2008-11-27 22:41:10 +00:00
Nick Lewycky
69941fd0a0
Add a couple of missed optimizations on integer vectors. Multiply and divide
...
by 1, as well as multiply by -1.
llvm-svn: 60182
2008-11-27 20:21:08 +00:00
Nick Lewycky
07d726ec4d
Optimize (x/y)*y into x-(x%y) in general. Div and rem are about the same, and
...
a subtract is cheaper than a multiply. This generalizes an existing transform.
llvm-svn: 59800
2008-11-21 07:33:58 +00:00
Chris Lattner
c3f3b059d0
Handle the case where there is no "not". It is possible it got
...
folded into the select.
llvm-svn: 59389
2008-11-16 04:25:26 +00:00
Chris Lattner
645f60141b
make this actually test what it is trying to.
...
llvm-svn: 59386
2008-11-16 04:21:51 +00:00
Bill Wendling
3f547be28f
If the LHS of the FCMP is coming from a UIToFP instruction, then we don't want
...
to generate signed ICMP instructions to replace the FCMP. This would violate
the following:
define i1 @test1(i32 %val) {
%1 = uitofp i32 %val to double
%2 = fcmp ole double %1, 0.000000e+00
ret i1 %2
}
would be transformed into:
define i1 @test1(i32 %val) {
%1 = icmp slt i33 %val, 1
ret i1 %1
}
which is obviously wrong. This patch modifes InstCombiner::FoldFCmp_IntToFP_Cst
to handle when the LHS comes from UIToFP.
llvm-svn: 58929
2008-11-09 04:26:50 +00:00
Nick Lewycky
8d8acf327b
Fix demanded bits analysis with srem by negative number. Based on a patch
...
by Richard Osborne.
llvm-svn: 58555
2008-11-02 02:41:50 +00:00
Dan Gohman
83eea0b17f
Fix this recently moved code to use the correct type. CI is now a
...
ConstantInt, and SI is the original cast instruction. This fixes
PR2996.
llvm-svn: 58549
2008-11-02 00:17:33 +00:00
Dan Gohman
13cbcf1c18
Canonicalize sext(i1) to i1?-1:0, and update various instcombine
...
optimizations accordingly.
llvm-svn: 58457
2008-10-30 20:40:10 +00:00
Dan Gohman
2c34c130bf
(A & sext(C)) | (B & ~sext(C) -> C ? A : B
...
llvm-svn: 58351
2008-10-28 22:38:57 +00:00
Nick Lewycky
730d5dade6
Don't try to create a mask when we don't need one. Fixes a crash.
...
llvm-svn: 58075
2008-10-24 06:14:27 +00:00
Dan Gohman
bc0278400c
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
d885f6e139
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
ce70752b11
- 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
67786cce66
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
Chris Lattner
da435910e8
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
Chris Lattner
917a6c1343
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
Nick Lewycky
e8ced3ec19
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
Dan Gohman
dafa9c6e85
Improve instcombine's handling of integer min and max in two ways:
...
- Recognize expressions like "x > -1 ? x : 0" as min/max and turn them
into expressions like "x < 0 ? 0 : x", which is easily recognizable
as a min/max operation.
- Refrain from folding expression like "y/2 < 1" to "y < 2" when the
comparison is being used as part of a min or max idiom, like
"y/2 < 1 ? 1 : y/2". In that case, the division has another use, so
folding doesn't eliminate it, and obfuscates the min/max, making it
harder to recognize as a min/max operation.
These benefit ScalarEvolution, CodeGen, and anything else that wants to
recognize integer min and max.
llvm-svn: 56246
2008-09-16 18:46:06 +00:00
Dan Gohman
eff71f2953
On 64-bit targets, change 32-bit getelementptr indices to be 64-bit
...
getelementptr indices, inserting an explicit cast if necessary.
This helps expose the sign-extension operation to other optimizations.
llvm-svn: 56133
2008-09-11 23:06:38 +00:00
Dan Gohman
7d01c0654c
Fix a vectorshuffle instcombine bug introduced by r55995.
...
Patch by Nicolas Capens!
llvm-svn: 56129
2008-09-11 22:47:57 +00:00
Dan Gohman
c1ae01688f
Fix an icmp+sdiv optimization to check for and handle an overflow
...
condition. This fixes PR2740.
llvm-svn: 56076
2008-09-10 23:30:57 +00:00
Dan Gohman
86fb5b48de
Make SimplifyDemandedVectorElts simplify vectors with multiple
...
users, and teach it about shufflevector instructions.
Also, fix a subtle bug in SimplifyDemandedVectorElts'
insertelement code.
This is a patch that was originally written by Eli Friedman,
with some fixes and cleanup by me.
llvm-svn: 55995
2008-09-09 18:11:14 +00:00
Nick Lewycky
f023db6444
Don't crash when trying to constant fold a vector with some elements that can't
...
be folded. Instead, fail to fold the entire vector.
We could also return a vector with some elements folded and some not. If anyone
thinks that's a better approach, please speak up!
llvm-svn: 55689
2008-09-03 05:54:33 +00:00
Nick Lewycky
99f4558117
Revert r54876 r54877 r54906 and r54907. Evan found that these caused a 20%
...
slowdown in bzip2.
llvm-svn: 55113
2008-08-21 05:56:10 +00:00
Nick Lewycky
53b44029d6
Consider the case where xor by -1 and xor by 128 have been combined already to
...
produce an xor by 127.
llvm-svn: 54906
2008-08-17 19:58:24 +00:00
Nick Lewycky
18f50b2637
Xor'ing both sides of icmp by sign-bit is equivalent to swapping signedness of
...
the predicate.
Also, make this optz'n apply in more cases where it's safe to do so.
llvm-svn: 54876
2008-08-17 07:34:14 +00:00
Owen Anderson
2a6adfa4f0
Remove GCSE and LoadVN from the testsuite.
...
llvm-svn: 54832
2008-08-16 00:00:54 +00:00
Dan Gohman
6134fbccef
Fix a bogus srem rule - a negative value srem'd by a power-of-2
...
can have a non-negative result; for example, -16%16 is 0. Also,
clarify the related comments. This fixes PR2670.
llvm-svn: 54767
2008-08-13 23:12:35 +00:00
Chris Lattner
2aa0ff27aa
Implement support for simplifying vector comparisons by 0.0 and 1.0 like we
...
do for scalars. Patch contributed by Nicolas Capens
This also generalizes the previous xforms to work on long double, now that
isExactlyValue works for long double.
llvm-svn: 54653
2008-08-11 22:06:05 +00:00
Dan Gohman
ac22cfcae9
Fix a shufflevector instcombine that was emitting invalid masks indices
...
when it meant to be emitting undef indices.
llvm-svn: 54417
2008-08-06 18:17:32 +00:00
Chris Lattner
f5b353c1fd
optimize a common idiom generated by clang for bitfield access, PR2638.
...
llvm-svn: 54408
2008-08-06 07:35:52 +00:00
Chris Lattner
7bdaecb7f4
Zap sitofp/fptoui pairs. In all cases when the sign difference
...
matters, the result is undefined anyway.
llvm-svn: 54396
2008-08-06 05:13:06 +00:00
Nick Lewycky
bf42893567
Reinstate this optimization, but without the miscompile. Thanks to Bill for
...
tracking down that this was breaking llvm-gcc bootstrap on Linux.
llvm-svn: 54394
2008-08-06 04:54:03 +00:00
Bill Wendling
0e966d3e2c
Just grep for through the LL code instead of the ASM code
...
llvm-svn: 54389
2008-08-06 00:10:32 +00:00
Bill Wendling
bc6786e7ee
Add default architecture.
...
llvm-svn: 54384
2008-08-05 23:36:00 +00:00
Bill Wendling
3dfa168d22
Testcase for PR2629.
...
llvm-svn: 54377
2008-08-05 22:23:59 +00:00
Bill Wendling
ee12a7aeff
Revert r53282. This was causing a miscompile on Linux. Also, the transformation
...
looks bogus. Please see PR2629 for details on why this is breaking things.
llvm-svn: 54372
2008-08-05 21:23:45 +00:00
Chris Lattner
c600c53d1f
Fix PR2553
...
llvm-svn: 53715
2008-07-17 06:07:20 +00:00
Matthijs Kooijman
f22f34f0cc
Add a few cases to instcombine's extractvalue testcase.
...
llvm-svn: 53675
2008-07-16 12:57:25 +00:00
Evan Cheng
c97094552c
Fix PR2296. Do not transform x86_sse2_storel_dq into a full-width store.
...
llvm-svn: 53666
2008-07-16 07:28:14 +00:00