Commit Graph

2728 Commits

Author SHA1 Message Date
Chris Lattner
5eecb7f164 This adds in some code (currently disabled unless you pass
-enable-smarter-addr-folding to llc) that gives CGP a better
cost model for when to sink computations into addressing modes.
The basic observation is that sinking increases register 
pressure when part of the addr computation has to be available
for other reasons, such as having a use that is a non-memory
operation.  In cases where it works, it can substantially reduce
register pressure.

This code is currently an overall win on 403.gcc and 255.vortex
(the two things I've been looking at), but there are several 
things I want to do before enabling it by default:

1. This isn't doing any caching of results, so it is much slower 
   than it could be.  It currently slows down release-asserts llc 
   by 1.7% on 176.gcc: 27.12s -> 27.60s.
2. This doesn't think about inline asm memory operands yet.
3. The cost model botches the case when the needed value is live
   across the computation for other reasons.

I'll continue poking at this, and eventually turn it on as llcbeta.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60074 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 02:00:14 +00:00
Evan Cheng
794a7dbce0 Revert r60042. IndVarSimplify should check if APFloat is PPCDoubleDouble first before trying to convert it to an integer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60072 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 01:11:57 +00:00
Chris Lattner
2efbbb38ba Teach CodeGenPrepare to look through Bitcast instructions when attempting to
optimize addressing modes.  This allows us to optimize things like isel-sink2.ll
into:

	movl	4(%esp), %eax
	cmpb	$0, 4(%eax)
	jne	LBB1_2	## F
LBB1_1:	## TB
	movl	$4, %eax
	ret
LBB1_2:	## F
	movzbl	7(%eax), %eax
	ret

instead of:

_test:
	movl	4(%esp), %eax
	cmpb	$0, 4(%eax)
	leal	4(%eax), %eax
	jne	LBB1_2	## F
LBB1_1:	## TB
	movl	$4, %eax
	ret
LBB1_2:	## F
	movzbl	3(%eax), %eax
	ret

This shrinks (e.g.) 403.gcc from 1133510 to 1128345 lines of .s.

Note that the 2008-10-16-SpillerBug.ll testcase is dubious at best, I doubt
it is really testing what it thinks it is.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60068 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-26 00:26:16 +00:00
Chris Lattner
3b48501adc Teach MatchScaledValue to handle Scales by 1 with MatchAddr (which
can recursively match things) and scales by 0 by ignoring them.
This triggers once in 403.gcc, saving 1 (!!!!) instruction in the 
whole huge app.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60013 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 07:25:26 +00:00
Chris Lattner
88a5c832ac significantly refactor all the addressing mode matching logic
into a new AddressingModeMatcher class.  This makes it easier
to reason about and reduces passing around of stuff, but has
no functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60012 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 07:09:13 +00:00
Chris Lattner
bb3204a440 refactor all the constantexpr/instruction handling code out into a
new FindMaximalLegalAddressingModeForOperation helper method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60011 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 05:15:49 +00:00
Chris Lattner
7ad1c7342b another minor tweak
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60010 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 04:47:41 +00:00
Chris Lattner
088a1e84ea minor cleanups no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60009 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-25 04:42:10 +00:00
Chris Lattner
85fa13c02d rearrange and tidy some code, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59990 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 22:44:16 +00:00
Chris Lattner
4744d85c50 minor cleanups to debug code, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59989 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 22:40:05 +00:00
Chris Lattner
ae297f8da5 reenable the right part of the code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59985 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 21:26:21 +00:00
Chris Lattner
7f2d6efbaa revert an accidental commit, this fixes the regression on test/CodeGen/X86/isel-sink.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59976 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 19:40:34 +00:00
Chris Lattner
47f5751c80 Fix 3113: If we have a dead cyclic PHI, replace the whole thing
with an undef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59972 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-24 19:25:36 +00:00
Devang Patel
50cacb2a52 Fix build failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59844 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 21:00:20 +00:00
Devang Patel
59500c8f9a Silence unused variable warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59841 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 20:00:59 +00:00
Chris Lattner
824b958e6f reapply Sanjiv's patch to genericize memcpy/memset/memmove to take an
arbitrary integer width for the count.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59823 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 16:42:48 +00:00
Bill Wendling
dc770929cb 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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59809 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 09:09:41 +00:00
Sanjiv Gupta
219ab405e6 Make mem[cpy,move,set] intrinsics overloaded.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59802 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 07:49:09 +00:00
Nick Lewycky
0c73079855 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59800 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 07:33:58 +00:00
Devang Patel
cb9a354d13 Fix unused variable warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59778 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-21 01:52:59 +00:00
Devang Patel
b8f69c65df Let instcombiner remove redundant dbg intrinsics.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59658 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 18:59:41 +00:00
Devang Patel
7fe1decf3a 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59657 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-19 18:56:50 +00:00
Bill Wendling
9bef70609c Cast to remove warning about comparing signed and unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59518 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 10:57:27 +00:00
Devang Patel
13877bf6c2 Give SIToFPInst preference over UIToFPInst because it is faster on platforms that are widely used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59476 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-18 00:40:02 +00:00
Devang Patel
cd40233429 While handling floating point IVs lift restrictions on initial value and increment value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59471 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 23:27:13 +00:00
Devang Patel
84e3515974 Handle floating point ivs during doInitialization().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59466 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-17 21:32:02 +00:00
Chris Lattner
1a6111f32d eliminate some std::set's.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59409 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 07:17:51 +00:00
Chris Lattner
cb504b95c5 simplify a bunch more instcombines to use m_Specific etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59403 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 05:38:51 +00:00
Chris Lattner
69d4ced68d factor the code for simplifying (icmp)|(icmp) into its own function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59402 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 05:20:07 +00:00
Chris Lattner
aa3e157845 do some computation with apints instead of ConstantInts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59401 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 05:14:43 +00:00
Chris Lattner
ea065fbdd8 merge a check into a place where it is simpler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59400 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 05:10:52 +00:00
Chris Lattner
29cd5ba621 factor a whole bunch of code out into a helper function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59398 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 05:06:21 +00:00
Chris Lattner
b9553d693b simplify the conditions on two gigantic if's, decreasing indentation
a bit.  Next step is to factor out into their own helper functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59397 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:55:20 +00:00
Chris Lattner
6046fb7bef simplify some instcombine matches by using m_Specific
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59395 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:46:19 +00:00
Chris Lattner
321e6a6e82 Use new m_SelectCst template to eliminate macros.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59392 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:33:38 +00:00
Chris Lattner
a6a474dca9 simplify code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59390 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:26:55 +00:00
Chris Lattner
a74cefa6d3 Handle the case where there is no "not". It is possible it got
folded into the select.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59389 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:25:26 +00:00
Chris Lattner
faaf951fab factor a bunch of copy/paste code out into a helper function.
Eliminate the cases checking for cond?0:-1, since that is already
handled by commutative checking.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59388 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 04:24:12 +00:00
Chris Lattner
1ca0c9922b rearrange some code, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59381 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 03:56:24 +00:00
Chris Lattner
7d3b4e92ab if we're going to use a macro, use it maximally. no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59380 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-16 03:54:57 +00:00
Devang Patel
35275f499a Cleanup debug info. assocated with deleted instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59012 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-11 00:54:10 +00:00
Devang Patel
d4e7f44319 If the sign of exit condition and split condition does not match
then do not split loop index.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58995 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10 19:48:34 +00:00
Bill Wendling
11bb6c6d2c Third time's a charm.
The previous patches didn't match correctly. Also, we need to make sure that
the conditional is the same before doing the transformation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58978 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10 06:59:06 +00:00
Mon P Wang
aeb06d2462 Added support for the following definition of shufflevector
<result> = shufflevector <n x <ty>> <v1>, <n x <ty>> <v2>, <m x i32> <mask> 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58964 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-10 04:46:22 +00:00
Bill Wendling
8f24cc237f Correction for the last patch. Should match the conditional in the first part
of the select match, not the select instruction itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58947 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-09 23:37:53 +00:00
Bill Wendling
1fb43c32ed The method of doing the matching with a 'select' instruction was wrong. The
original code was matching like this:

	if (match(A, m_Not(m_Value(B))))

B was already matched as a 'select' instruction. However, this isn't matching
what we think it's matching. It would match B as a 'Value', so basically
anything would match to it. In this case, a Constant matched. B was replaced
with a constant representation. And then the wrong value would be used in the
SelectInst::Create statement, causing a crash.

After thinking on this for a moment, and after Nick L. told me how the pattern
matching stuff was supposed to work, the solution was to match NOT an m_Value,
but an m_Select.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58946 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-09 23:17:42 +00:00
Nuno Lopes
ea736cee2b fix leakage of ValueNumbering
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58933 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-09 12:45:23 +00:00
Bill Wendling
c143bcf9ac 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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58929 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-09 04:26:50 +00:00
Mon P Wang
e0b436ac41 Fixed scalarizing an extract subvector and prevent an infinite loop
when simplify a vector. 


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58820 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-06 22:52:21 +00:00
Oscar Fuentes
436893d924 CMake: updated list of source files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58736 91177308-0d34-0410-b5e6-96231b3b80d8
2008-11-05 00:11:22 +00:00