Chris Lattner
2fdcc59bb6
Change m_ConstantInt and m_SelectCst to take their constant integers
...
as template arguments instead of as instance variables, exposing more
optimization opportunities to the compiler earlier.
llvm-svn: 61776
2009-01-05 23:53:12 +00:00
Bill Wendling
0c04f9fdc3
Revert this transform. It was causing some dramatic slowdowns in a few tests. See PR3266.
...
llvm-svn: 61623
2009-01-04 06:19:11 +00:00
Bill Wendling
0fcff2c203
Fix comment.
...
llvm-svn: 61538
2009-01-01 01:19:59 +00:00
Bill Wendling
aedb54a947
Add transformation:
...
xor (or (icmp, icmp), true) -> and(icmp, icmp)
This is possible because of De Morgan's law.
llvm-svn: 61537
2009-01-01 01:18:23 +00:00
Nick Lewycky
4bc10c9e77
Remove redundant test for vector-nature. Scan the vector first to see whether
...
our optz'n will apply to it, then build the replacement vector only if needed.
llvm-svn: 61279
2008-12-20 16:48:00 +00:00
Nick Lewycky
c3a70ade66
Oops! Left out a line.
...
Simplifying the sdiv might allow further simplifications for our users.
llvm-svn: 61196
2008-12-18 06:42:28 +00:00
Nick Lewycky
0f0e63fe73
Make all the vector elements positive in an srem of constant vector.
...
llvm-svn: 61195
2008-12-18 06:31:11 +00:00
Bill Wendling
87beb9b909
Remove some errors that crept in. No functionality change.
...
llvm-svn: 60403
2008-12-02 06:24:20 +00:00
Bill Wendling
790b4bf9a9
Merge two if-statements into one.
...
llvm-svn: 60402
2008-12-02 06:22:04 +00:00
Bill Wendling
5635295266
More styalistic changes. No functionality change.
...
llvm-svn: 60401
2008-12-02 06:18:11 +00:00
Bill Wendling
85de4b35ca
- Remove the buggy -X/C -> X/-C transform. This isn't valid when X isn't a
...
constant. If X is a constant, then this is folded elsewhere.
- Added a note to Target/README.txt to indicate that we'd like to implement
this when we're able.
llvm-svn: 60399
2008-12-02 05:12:47 +00:00
Bill Wendling
5369db5917
Improve comment.
...
llvm-svn: 60398
2008-12-02 05:09:00 +00:00
Bill Wendling
21716dff5e
- Reduce nesting.
...
- No need to do a swap on a canonicalized pattern.
No functionality change.
llvm-svn: 60397
2008-12-02 05:06:43 +00:00
Bill Wendling
6f71bce4cf
Don't rebuild RHSNeg. Just use the one that's already there.
...
llvm-svn: 60370
2008-12-01 21:06:30 +00:00
Bill Wendling
84f6f2539f
Document what this check is doing. Also, no need to cast to ConstantInt.
...
llvm-svn: 60369
2008-12-01 21:03:43 +00:00
Bill Wendling
e6c87a4952
Use a simple comparison. Overflow on integer negation can only occur when the
...
integer is "minint".
llvm-svn: 60366
2008-12-01 19:46:27 +00:00
Bill Wendling
47f733e4ea
Generalize the FoldOrWithConstant method to fold for any two constants which
...
don't have overlapping bits.
llvm-svn: 60344
2008-12-01 08:32:40 +00:00
Bill Wendling
22e761b302
Reduce copy-and-paste code by splitting out the code into its own function.
...
llvm-svn: 60343
2008-12-01 08:23:25 +00:00
Bill Wendling
582fe6b0ca
Use m_Specific() instead of double matching.
...
llvm-svn: 60341
2008-12-01 08:09:47 +00:00
Bill Wendling
4eecfb655b
Move pattern check outside of the if-then statement. This prevents us from fiddling with constants unless we have to.
...
llvm-svn: 60340
2008-12-01 07:47:02 +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
084b3a47d3
Change instcombine to use FoldPHIArgGEPIntoPHI to fold two operand PHIs
...
instead of using FoldPHIArgBinOpIntoPHI. In addition to being more
obvious, this also fixes a problem where instcombine wouldn't merge two
phis that had different variable indices. This prevented instcombine
from factoring big chunks of code in 403.gcc. For example:
insn_cuid.exit:
- %tmp336 = load i32** @uid_cuid, align 4
- %tmp337 = getelementptr %struct.rtx_def* %insn_addr.0.ph.i, i32 0, i32 3
- %tmp338 = bitcast [1 x %struct.rtunion]* %tmp337 to i32*
- %tmp339 = load i32* %tmp338, align 4
- %tmp340 = getelementptr i32* %tmp336, i32 %tmp339
br label %bb62
bb61:
- %tmp341 = load i32** @uid_cuid, align 4
- %tmp342 = getelementptr %struct.rtx_def* %insn, i32 0, i32 3
- %tmp343 = bitcast [1 x %struct.rtunion]* %tmp342 to i32*
- %tmp344 = load i32* %tmp343, align 4
- %tmp345 = getelementptr i32* %tmp341, i32 %tmp344
br label %bb62
bb62:
- %iftmp.62.0.in = phi i32* [ %tmp345, %bb61 ], [ %tmp340, %insn_cuid.exit ]
+ %insn.pn2 = phi %struct.rtx_def* [ %insn, %bb61 ], [ %insn_addr.0.ph.i, %insn_cuid.exit ]
+ %tmp344.pn.in.in = getelementptr %struct.rtx_def* %insn.pn2, i32 0, i32 3
+ %tmp344.pn.in = bitcast [1 x %struct.rtunion]* %tmp344.pn.in.in to i32*
+ %tmp341.pn = load i32** @uid_cuid
+ %tmp344.pn = load i32* %tmp344.pn.in
+ %iftmp.62.0.in = getelementptr i32* %tmp341.pn, i32 %tmp344.pn
%iftmp.62.0 = load i32* %iftmp.62.0.in
llvm-svn: 60325
2008-12-01 03:42:51 +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
Eli Friedman
11c15a5de7
Minor cleanup: use getTrue and getFalse where appropriate. No
...
functional change.
llvm-svn: 60307
2008-11-30 22:48:49 +00:00
Eli Friedman
55e4becba9
Some minor cleanups to instcombine; no functionality change.
...
Note that the FoldOpIntoPhi call is dead because it's impossible for the
first operand of a subtraction to be both a ConstantInt and a PHINode.
llvm-svn: 60306
2008-11-30 21:09: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
2fe3229824
Forgot one remaining call to getSExtValue().
...
llvm-svn: 60289
2008-11-30 12:41:09 +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
7abf352f44
Don't make TwoToExp signed by default.
...
llvm-svn: 60279
2008-11-30 05:29:33 +00:00
Bill Wendling
af200e9237
From Hacker's Delight:
...
"For signed integers, the determination of overflow of x*y is not so simple. If
x and y have the same sign, then overflow occurs iff xy > 2**31 - 1. If they
have opposite signs, then overflow occurs iff xy < -2**31."
In this case, x == -1.
llvm-svn: 60278
2008-11-30 05:01:05 +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
Chris Lattner
e0d019def6
switch InstCombine::visitLoadInst to use
...
FindAvailableLoadedValue
llvm-svn: 60169
2008-11-27 08:56:30 +00:00
Chris Lattner
dd7083452f
reapply Sanjiv's patch to genericize memcpy/memset/memmove to take an
...
arbitrary integer width for the count.
llvm-svn: 59823
2008-11-21 16:42:48 +00:00
Bill Wendling
4bce2bff88
Revert r59802. It was breaking the build of llvm-gcc:
...
g++ -m32 -c -g -DIN_GCC -W -Wall -Wwrite-strings -Wmissing-format-attribute -fno-common -mdynamic-no-pic -DHAVE_CONFIG_H -Wno-unused -DTARGET_NAME=\"i386-apple-darwin9.5.0\" -I. -I. -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/. -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include -DENABLE_LLVM -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/../llvm.src/include -D_DEBUG -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -I. -I. -I../../llvm-gcc.src/gcc -I../../llvm-gcc.src/gcc/. -I../../llvm-gcc.src/gcc/../include -I./../intl -I../../llvm-gcc.src/gcc/../libcpp/include -I../../llvm-gcc.src/gcc/../libdecnumber -I../libdecnumber -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.obj/include -I/Volumes/Sandbox/Buildbot/llvm/full-llvm/build/llvm.src/include ../../llvm-gcc.src/gcc/llvm-types.cpp -o llvm-types.o
../../llvm-gcc.src/gcc/llvm-convert.cpp: In member function 'void TreeToLLVM::EmitMemCpy(llvm::Value*, llvm::Value*, llvm::Value*, unsigned int)':
../../llvm-gcc.src/gcc/llvm-convert.cpp:1496: error: 'memcpy_i32' is not a member of 'llvm::Intrinsic'
../../llvm-gcc.src/gcc/llvm-convert.cpp:1496: error: 'memcpy_i64' is not a member of 'llvm::Intrinsic'
../../llvm-gcc.src/gcc/llvm-convert.cpp: In member function 'void TreeToLLVM::EmitMemMove(llvm::Value*, llvm::Value*, llvm::Value*, unsigned int)':
../../llvm-gcc.src/gcc/llvm-convert.cpp:1512: error: 'memmove_i32' is not a member of 'llvm::Intrinsic'
../../llvm-gcc.src/gcc/llvm-convert.cpp:1512: error: 'memmove_i64' is not a member of 'llvm::Intrinsic'
../../llvm-gcc.src/gcc/llvm-convert.cpp: In member function 'void TreeToLLVM::EmitMemSet(llvm::Value*, llvm::Value*, llvm::Value*, unsigned int)':
../../llvm-gcc.src/gcc/llvm-convert.cpp:1528: error: 'memset_i32' is not a member of 'llvm::Intrinsic'
../../llvm-gcc.src/gcc/llvm-convert.cpp:1528: error: 'memset_i64' is not a member of 'llvm::Intrinsic'
make[3]: *** [llvm-convert.o] Error 1
make[3]: *** Waiting for unfinished jobs....
rm fsf-funding.pod gcov.pod gfdl.pod cpp.pod gpl.pod gcc.pod
make[2]: *** [all-stage1-gcc] Error 2
make[1]: *** [stage1-bubble] Error 2
make: *** [all] Error 2
llvm-svn: 59809
2008-11-21 09:09:41 +00:00
Sanjiv Gupta
09a203765a
Make mem[cpy,move,set] intrinsics overloaded.
...
llvm-svn: 59802
2008-11-21 07:49:09 +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
Devang Patel
7ed6c5317c
If there are two consecutive llvm.dbg.stoppoint calls then
...
it is likely that the optimizer deleted code in between these
two intrinsics. Keep only the last llvm.dbg.stoppoint in this case.
llvm-svn: 59657
2008-11-19 18:56:50 +00:00
Chris Lattner
44152742a0
simplify a bunch more instcombines to use m_Specific etc.
...
llvm-svn: 59403
2008-11-16 05:38:51 +00:00
Chris Lattner
d397fef50d
factor the code for simplifying (icmp)|(icmp) into its own function.
...
llvm-svn: 59402
2008-11-16 05:20:07 +00:00
Chris Lattner
909b969b18
do some computation with apints instead of ConstantInts.
...
llvm-svn: 59401
2008-11-16 05:14:43 +00:00
Chris Lattner
feaea9bdf7
merge a check into a place where it is simpler.
...
llvm-svn: 59400
2008-11-16 05:10:52 +00:00
Chris Lattner
269cbd5770
factor a whole bunch of code out into a helper function.
...
llvm-svn: 59398
2008-11-16 05:06:21 +00:00
Chris Lattner
b37b6e7e96
simplify the conditions on two gigantic if's, decreasing indentation
...
a bit. Next step is to factor out into their own helper functions.
llvm-svn: 59397
2008-11-16 04:55:20 +00:00
Chris Lattner
f1be285134
simplify some instcombine matches by using m_Specific
...
llvm-svn: 59395
2008-11-16 04:46:19 +00:00
Chris Lattner
fae5e33111
Use new m_SelectCst template to eliminate macros.
...
llvm-svn: 59392
2008-11-16 04:33:38 +00:00
Chris Lattner
569d78cbb5
simplify code.
...
llvm-svn: 59390
2008-11-16 04:26:55 +00:00