Nick Lewycky
8f3127c5b5
Typo.
...
llvm-svn: 51475
2008-05-23 04:39:38 +00:00
Nick Lewycky
4f3d878507
Revert X + X --> X * 2 optz'n which pessimizes heavily on x86.
...
llvm-svn: 51474
2008-05-23 04:34:58 +00:00
Nick Lewycky
452fb32927
Implement X + X for vectors.
...
llvm-svn: 51472
2008-05-23 04:14:51 +00:00
Nick Lewycky
2ec9a01173
Fix a recently added optimization to not crash on vectors.
...
llvm-svn: 51471
2008-05-23 03:26:47 +00:00
Dan Gohman
6d5f120c5c
Generalize the new code in instcombine's ComputeNumSignBits for handling
...
and/or to handle more cases (such as this add-sitofp.ll testcase), and
port it to selectiondag's ComputeNumSignBits.
llvm-svn: 51469
2008-05-23 02:28:01 +00:00
Dan Gohman
53b2698531
Use isSingleValueType instead of isFirstClassType to
...
exclude struct and array types.
llvm-svn: 51467
2008-05-23 01:52:21 +00:00
Dale Johannesen
fecb88249f
Allow for switch with no cases. Was causing fault
...
in gcc.dg/pr27531-1.c.
llvm-svn: 51464
2008-05-23 01:01:31 +00:00
Dan Gohman
30ab45d01e
Use isSingleValueType instead of isFirstClassType to
...
exclude struct and array types.
llvm-svn: 51459
2008-05-23 00:17:26 +00:00
Dan Gohman
7a0566b9cd
Use isSingleValueType instead of isFirstClassType to
...
exclude struct and array types.
llvm-svn: 51456
2008-05-23 00:12:03 +00:00
Chris Lattner
c5ec1e19eb
rewrite the validity checking for memory promotion to be simpler,
...
more aggressive, and more correct. Verify that we only attempt to
promote loads and stores.
llvm-svn: 51406
2008-05-22 03:22:42 +00:00
Chris Lattner
f12c08dcd8
Use 'continue' to reduce nesting in this loop. No functionality change.
...
llvm-svn: 51399
2008-05-22 00:53:38 +00:00
Dan Gohman
e62632e0bb
When LSR is replacing an instruction, call
...
ScalarEvolution::deleteValueFromRecords on it before doing the
replaceAllUsesWith, because ScalarEvolution looks at the instruction's
users to find SCEV references to the instruction's SCEV object in its
internal maps.
Move all of LSR's loop-related state clearing after processing the loop
and before cleaning up dead PHI nodes. This eliminates all of LSR's SCEV
references just before the calls to ScalarEvolution::deleteValueFromRecords
so that when ScalarEvolution drops its own SCEV references, the reference
counts will reach zero and the SCEVs will be deleted immediately.
These changes fix some compiler aborts involving ScalarEvolution holding
onto and reusing SCEV objects for instructions that have been deleted.
No regression test unfortunately; because the symptoms were due to
dangling pointers, reduced testcases ended up being fairly arbitrary.
llvm-svn: 51359
2008-05-21 00:54:12 +00:00
Dan Gohman
81ab753b14
Port SelectionDAG's ComputeNumSignBits-using code to instcombine,
...
now that instcombine also has ComputeNumSignBits.
llvm-svn: 51350
2008-05-20 21:01:12 +00:00
Matthijs Kooijman
5148a4ba66
Fix typo.
...
llvm-svn: 51303
2008-05-20 07:26:45 +00:00
Chris Lattner
7ac943fffd
Teach instcombine 4 new xforms:
...
(add (sext x), cst) --> (sext (add x, cst'))
(add (sext x), (sext y)) --> (sext (add int x, y))
(add double (sitofp x), fpcst) --> (sitofp (add int x, intcst))
(add double (sitofp x), (sitofp y)) --> (sitofp (add int x, y))
This generally reduces conversions. For example MiBench/telecomm-gsm
gets these simplifications:
HACK2: %tmp67.i142.i.i = sext i16 %tmp6.i141.i.i to i32 ; <i32> [#uses=1]
%tmp23.i139.i.i = sext i16 %tmp2.i138.i.i to i32 ; <i32> [#uses=1]
%tmp8.i143.i.i = add i32 %tmp67.i142.i.i, %tmp23.i139.i.i ; <i32> [#uses=3]
HACK2: %tmp67.i121.i.i = sext i16 %tmp6.i120.i.i to i32 ; <i32> [#uses=1]
%tmp23.i118.i.i = sext i16 %tmp2.i117.i.i to i32 ; <i32> [#uses=1]
%tmp8.i122.i.i = add i32 %tmp67.i121.i.i, %tmp23.i118.i.i ; <i32> [#uses=3]
HACK2: %tmp67.i.i190.i = sext i16 %tmp6.i.i189.i to i32 ; <i32> [#uses=1]
%tmp23.i.i187.i = sext i16 %tmp2.i.i186.i to i32 ; <i32> [#uses=1]
%tmp8.i.i191.i = add i32 %tmp67.i.i190.i, %tmp23.i.i187.i ; <i32> [#uses=3]
HACK2: %tmp67.i173.i.i.i = sext i16 %tmp6.i172.i.i.i to i32 ; <i32> [#uses=1]
%tmp23.i170.i.i.i = sext i16 %tmp2.i169.i.i.i to i32 ; <i32> [#uses=1]
%tmp8.i174.i.i.i = add i32 %tmp67.i173.i.i.i, %tmp23.i170.i.i.i ; <i32> [#uses=3]
HACK2: %tmp67.i152.i.i.i = sext i16 %tmp6.i151.i.i.i to i32 ; <i32> [#uses=1]
%tmp23.i149.i.i.i = sext i16 %tmp2.i148.i.i.i to i32 ; <i32> [#uses=1]
%tmp8.i153.i.i.i = add i32 %tmp67.i152.i.i.i, %tmp23.i149.i.i.i ; <i32> [#uses=3]
HACK2: %tmp67.i.i.i.i = sext i16 %tmp6.i.i.i.i to i32 ; <i32> [#uses=1]
%tmp23.i.i5.i.i = sext i16 %tmp2.i.i.i.i to i32 ; <i32> [#uses=1]
%tmp8.i.i7.i.i = add i32 %tmp67.i.i.i.i, %tmp23.i.i5.i.i ; <i32> [#uses=3]
This also fixes a bug in ComputeNumSignBits handling select and
makes it more aggressive with and/or.
llvm-svn: 51302
2008-05-20 05:46:13 +00:00
Chris Lattner
9c27f96d04
fix two issues Neil noticed, thanks!
...
llvm-svn: 51296
2008-05-20 03:50:52 +00:00
Dan Gohman
e5572706e8
Refine the fix in r51169 to only apply when the operand val being
...
replaced is a PHI. This prevents it from inserting uses before defs
in the case that it isn't a PHI and it depends on other instructions
later in the block. This fixes the 447.dealII regression on x86-64.
llvm-svn: 51292
2008-05-20 03:01:48 +00:00
Dan Gohman
d717761a2b
Make AssociativeOpt static.
...
llvm-svn: 51290
2008-05-20 01:14:05 +00:00
Devang Patel
ee7bf41c06
Do not erase induction variable increment if it is used outside the loop.
...
llvm-svn: 51280
2008-05-19 22:23:55 +00:00
Dan Gohman
123438cc05
Add a ComputeNumSignBits function for use by instcombine, based on the
...
code in SelectionDAG.
llvm-svn: 51279
2008-05-19 22:14:15 +00:00
Chris Lattner
b42712288e
switch to Type::getFPMantissaWidth instead of reinventing it.
...
llvm-svn: 51275
2008-05-19 21:17:23 +00:00
Chris Lattner
ba9acbe6dc
minor cleanups, teach instcombine that sitofp/uitofp cannot
...
produce a negative zero.
llvm-svn: 51272
2008-05-19 20:27:56 +00:00
Chris Lattner
e35fe0f1c6
convert fptosi(sitofp x) -> x if the fp value has enough bits in its mantissa
...
to accurately represent the integer. This triggers 9 times in 471.omnetpp,
though 8 of those seem to be inlined from the same place.
llvm-svn: 51271
2008-05-19 20:25:04 +00:00
Chris Lattner
5920a78034
Fold FP comparisons where one operand is converted from an integer
...
type and the other operand is a constant into integer comparisons.
This happens surprisingly frequently (e.g. 10 times in 471.omnetpp),
which are things like this:
%tmp8283 = sitofp i32 %tmp82 to double
%tmp1013 = fcmp ult double %tmp8283, 0.0
Clearly comparing tmp82 against i32 0 is cheaper here.
this also triggers 8 times in gobmk, including this one:
%tmp375376 = sitofp i32 %tmp375 to double
%tmp377 = fcmp ogt double %tmp375376, 8.150000e+01
which is comparing an integer against 81.5 :).
llvm-svn: 51268
2008-05-19 20:18:56 +00:00
Chris Lattner
6e70830af9
remove debug output
...
llvm-svn: 51264
2008-05-19 20:03:53 +00:00
Chris Lattner
fc365b60dc
be more aggressive about transforming add -> or when the operands have no
...
intersecting bits. This triggers all over the place, for example in lencode,
with adds of stuff like:
%tmp580 = mul i32 %tmp579, 2
%tmp582 = and i32 %b8, 1
and
%tmp28 = shl i32 %abs.i, 1
%sign.0 = select i1 %tmp23, i32 1, i32 0
and
%tmp344 = shl i32 %tmp343, 2
%tmp346 = and i32 %tmp96, 3
etc.
llvm-svn: 51263
2008-05-19 20:01:56 +00:00
Duncan Sands
eec7a3c071
Fix PR2341 - when the length is 4 use an i32 not
...
an i16! Cleaned up trailing whitespace while there.
llvm-svn: 51240
2008-05-19 09:27:24 +00:00
Nate Begeman
65720c968c
Teach GVN to not assert on vector comparisons
...
llvm-svn: 51230
2008-05-18 19:49:05 +00:00
Chris Lattner
4b2a724fb8
Fix PR2339
...
llvm-svn: 51226
2008-05-18 04:11:26 +00:00
Nick Lewycky
79376f4e02
Move isTrueWhenEqual to ICmpInst.
...
llvm-svn: 51215
2008-05-17 07:33:39 +00:00
Dale Johannesen
5610dabac9
Less conservative verison of previous patch,
...
suggested by Duncan.
llvm-svn: 51211
2008-05-16 23:18:52 +00:00
Dale Johannesen
e7f5bc2c3b
Weak functions not declared non-throwing might be
...
replaced at linktime with a body that throws, even
if the body in this file does not. Make PruneEH
be more conservative in this case.
g++.dg/eh/weak1.C
llvm-svn: 51207
2008-05-16 21:31:48 +00:00
Gabor Greif
e1f6e4b21d
API change for {BinaryOperator|CmpInst|CastInst}::create*() --> Create. Legacy interfaces will be in place for some time. (Merge from use-diet branch.)
...
llvm-svn: 51200
2008-05-16 19:29:10 +00:00
Duncan Sands
67933e6692
Bill pointed out that system headers should be
...
included after local headers.
llvm-svn: 51187
2008-05-16 09:30:00 +00:00
Evan Cheng
173a53f87c
Do not dup malloc, vector instructions, etc. Throttle the default theshold way down.
...
llvm-svn: 51183
2008-05-16 07:55:50 +00:00
Owen Anderson
c7d6eceb69
Remove ADCE's ability to delete loops. This ability is now implemented in a
...
safer manner by loop deletion.
llvm-svn: 51182
2008-05-16 04:34:51 +00:00
Owen Anderson
ad5f211b48
Clean ups for loop deletion based on Chris' feedback.
...
Also, use SCEV to determine the trip count of the loop, which is more powerful
and accurate that Loop::getTripCount.
llvm-svn: 51179
2008-05-16 04:32:45 +00:00
Chris Lattner
5c953b7d27
implement PR2328.
...
llvm-svn: 51176
2008-05-16 02:59:42 +00:00
Dan Gohman
0a0fa7cf78
Fix a bug in LoopStrengthReduce that caused it to emit IR with
...
use-before-def. The problem comes up in code with multiple PHIs where
one PHI is being rewritten in terms of the other, but the other needs
to be casted first. LLVM rules requre the cast instruction to be
inserted after any PHI instructions, but when instructions were
inserted to replace the second PHI value with a function of the first,
they were ended up going before the cast instruction. Avoid this
problem by remembering the location of the cast instruction, when one
is needed, and inserting the expansion of the new value after it.
This fixes a bug that surfaced in 255.vortex on x86-64 when
instcombine was removed from the middle of the loop optimization
passes.
llvm-svn: 51169
2008-05-15 23:26:57 +00:00
Devang Patel
61724355af
Remove useless check.
...
Patch by Matthijs Kooijman.
llvm-svn: 51154
2008-05-15 18:04:29 +00:00
Duncan Sands
783cb2d76d
Use of UINT_MAX requires climits, at least when
...
compiling with gcc 4.3.
llvm-svn: 51145
2008-05-15 11:22:50 +00:00
Gabor Greif
697e94cc22
Fix a bunch of 80col violations that arose from the Create API change. Tweak makefile targets to find these better.
...
llvm-svn: 51143
2008-05-15 10:04:30 +00:00
Bill Wendling
3716952f10
Situations can arise when you have a function called that returns a 'void', but
...
is bitcast to return a floating point value. The result of the instruction may
not be used by the program afterwards, and LLVM will happily remove all
instructions except the call. But, on some platforms, if a value is returned as
a floating point, it may need to be removed from the stack (like x87). Thus, we
can't get rid of the bitcast even if there isn't a use of the value.
llvm-svn: 51134
2008-05-14 22:45:20 +00:00
Chris Lattner
e15051d64b
rename SimplifyCFG.cpp -> SimplifyCFGPass.cpp
...
llvm-svn: 51130
2008-05-14 20:38:44 +00:00
Devang Patel
f2763e233e
Simplify internalize pass. Add test case.
...
Patch by Matthijs Kooijman!
llvm-svn: 51114
2008-05-14 20:01:01 +00:00
Dan Gohman
3dc2d92ebd
Split the loop unroll mechanism logic out into a utility function.
...
Patch by Matthijs Kooijman!
llvm-svn: 51083
2008-05-14 00:24:14 +00:00
Owen Anderson
17816b321f
Fix Analysis/BasicAA/pure-const-dce.ll. This turned out to be a correctness
...
bug as well as a missed optimization. We weren't properly checking for local
dependencies before moving on to non-local ones when doing non-local read-only
call CSE.
llvm-svn: 51082
2008-05-13 23:18:30 +00:00
Dale Johannesen
e695ab227c
Fix for PR 2323, infinite loop in tail dup.
...
llvm-svn: 51063
2008-05-13 20:06:43 +00:00
Owen Anderson
8c2391d00d
Make the non-local CSE safety checks slightly more thorough.
...
llvm-svn: 51035
2008-05-13 13:41:23 +00:00
Owen Anderson
69057b80c7
Add support for non-local CSE of read-only calls.
...
llvm-svn: 51024
2008-05-13 08:17:22 +00:00
Dan Gohman
0479aa5c0b
Change class' public PassInfo variables to by initialized with the
...
address of the PassInfo directly instead of calling getPassInfo.
This eliminates a bunch of dynamic initializations of static data.
Also, fold RegisterPassBase into PassInfo, make a bunch of its
data members const, and rearrange some code to initialize data
members in constructors instead of using setter member functions.
llvm-svn: 51022
2008-05-13 02:05:11 +00:00
Nate Begeman
53c5c62d6d
80 col / tabs fixes
...
llvm-svn: 51021
2008-05-13 01:48:26 +00:00
Dan Gohman
d78c400b5b
Clean up the use of static and anonymous namespaces. This turned up
...
several things that were neither in an anonymous namespace nor static
but not intended to be global.
llvm-svn: 51017
2008-05-13 00:00:25 +00:00
Owen Anderson
f792860255
Go back to passing the analyses around as parameters.
...
llvm-svn: 50995
2008-05-12 20:15:55 +00:00
Owen Anderson
4afb1c864a
Move the various analyses used by GVN into static variables so we don't have to keep passing them around or refetching them.
...
llvm-svn: 50963
2008-05-12 08:15:27 +00:00
Chris Lattner
47fed61526
Fix various DOUTs to not call the extremely expensive Value::getName()
...
method. DOUT statements are disabled when assertions are off, but the
side effects of getName() are still evaluated. Just call getNameSTart,
which is close enough and doesn't cause heap traffic.
llvm-svn: 50958
2008-05-11 01:55:59 +00:00
Chris Lattner
82146fa267
Simplify code by using SwitchInst::findCaseValue instead of reimplementing it.
...
llvm-svn: 50957
2008-05-10 23:56:54 +00:00
Chris Lattner
a4ee1f516f
don't sink invokes, even if they are readonly. This fixes a
...
crash on kimwitu++.
llvm-svn: 50901
2008-05-09 15:07:33 +00:00
Duncan Sands
437435dcbc
Fix a type and formatting.
...
llvm-svn: 50900
2008-05-09 12:20:10 +00:00
Chris Lattner
aaba10e843
Implement PR2298. This transforms:
...
~x < ~y --> y < x
-x == -y --> x == y
llvm-svn: 50882
2008-05-09 05:19:28 +00:00
Chris Lattner
e7f0afe168
restore doxygen comment.
...
llvm-svn: 50881
2008-05-09 04:43:13 +00:00
Gordon Henriksen
829046b0b4
Improve pass documentation and comments.
...
Patch by Matthijs Kooijman!
llvm-svn: 50861
2008-05-08 17:46:35 +00:00
Chris Lattner
49a594e6ab
More than just loads can read from memory: readonly calls like strlen
...
also need to be checked for memory modifying instructions before we
can sink them. THis fixes the second half of PR2297.
llvm-svn: 50860
2008-05-08 17:37:37 +00:00
Chris Lattner
4fa09669d8
Make instcombine's DSE respect loads as well as stores. It is not safe to
...
delete the first store in:
store x -> p
load p
store y -> p
This is for PR2297.
llvm-svn: 50859
2008-05-08 17:20:30 +00:00
Devang Patel
4758caa926
Check linkage.
...
llvm-svn: 50851
2008-05-08 15:08:39 +00:00
Anton Korobeynikov
fc2edad4ae
Turn StripPointerCast() into a method
...
llvm-svn: 50836
2008-05-07 22:54:15 +00:00
Dan Gohman
5a3eecdfd8
Fix a bug in the ComputeMaskedBits logic for multiply.
...
llvm-svn: 50793
2008-05-07 00:35:55 +00:00
Anton Korobeynikov
82c02b28f3
Make StripPointerCast a common function (should we mak it method of Value instead?)
...
llvm-svn: 50775
2008-05-06 22:52:30 +00:00
Owen Anderson
0e1ab4a9be
We need to update PHIs containing the exiting block, not the exit block. We really should come up with better names for these.
...
llvm-svn: 50770
2008-05-06 20:55:16 +00:00
Devang Patel
7ffc3c9a95
Fix typo.
...
llvm-svn: 50713
2008-05-06 05:40:11 +00:00
Chris Lattner
de68fabb35
fix typo Duncan noticed
...
llvm-svn: 50699
2008-05-06 02:31:18 +00:00
Dan Gohman
6a2da37c0e
Make several variable declarations static.
...
llvm-svn: 50696
2008-05-06 01:53:16 +00:00
Dan Gohman
a8b7e78f54
Remove uses of llvm/System/IncludeFile.h that are no longer needed.
...
llvm-svn: 50695
2008-05-06 01:32:53 +00:00
Dan Gohman
cf0e3acf16
Correct the value of LowBits in srem and urem handling in
...
ComputeMaskedBits.
llvm-svn: 50692
2008-05-06 00:51:48 +00:00
Bill Wendling
4ead264c08
Fix: Some classes were derived from a class in an anonymous namespace, but they
...
themselves weren't in the anonymous namespace.
llvm-svn: 50673
2008-05-05 21:37:59 +00:00
Chris Lattner
8ed8e3d0e6
Fix a crash when threading a block that includes a MRV call result.
...
DemoteRegToStack doesn't work with MRVs yet, because it relies on the
ability to load/store things.
This fixes PR2285.
llvm-svn: 50667
2008-05-05 20:21:22 +00:00
Torok Edwin
2d7a4d70c3
processStore may delete the instruction, avoid
...
using dyn_cast<> on already freed memory.
llvm-svn: 50618
2008-05-04 08:51:25 +00:00
Devang Patel
fa0e3c4a92
Handle multiple return values.
...
llvm-svn: 50604
2008-05-03 01:12:15 +00:00
Devang Patel
a1ec89fbf1
Do not sink getresult.
...
llvm-svn: 50600
2008-05-03 00:36:30 +00:00
Dan Gohman
1962c2be6a
Fix a mistake in the computation of leading zeros for udiv.
...
llvm-svn: 50591
2008-05-02 21:30:02 +00:00
Chris Lattner
5f0563ceb6
strength reduce exp2 into ldexp, rdar://5852514
...
llvm-svn: 50586
2008-05-02 18:43:35 +00:00
Chris Lattner
a700b2bd0f
add a FIXME so we remember to eventually remove this code.
...
llvm-svn: 50582
2008-05-02 17:18:31 +00:00
Bill Wendling
86ceb0db9c
Porting r50563 from Tak to mainline.
...
llvm-svn: 50564
2008-05-02 00:43:20 +00:00
Dale Johannesen
78ffe6e939
Don't try to create PHIs of struct types. Fallout
...
from x86-64 calling convention work.
llvm-svn: 50545
2008-05-01 22:27:44 +00:00
Dan Gohman
4be6ae4e6c
Fix an overaggressive SimplifyDemandedBits optimization on urem. This
...
fixes the 254.gap regression on x86 and the 403.gcc regression on x86-64.
llvm-svn: 50537
2008-05-01 19:13:24 +00:00
Chris Lattner
bb41aab426
1) add '-debug' output
...
2) Return NULL instead of false in several places for tidiness.
3) fix a bug optimizing sprintf(p, "%c", x)
llvm-svn: 50521
2008-05-01 06:39:12 +00:00
Chris Lattner
b9b5d6ddaa
Delete the IPO simplify-libcalls and completely reimplement it as
...
a FunctionPass. This makes it simpler, fixes dozens of bugs, adds
a couple of minor features, and shrinks is considerably: from
2214 to 1437 lines.
llvm-svn: 50520
2008-05-01 06:25:24 +00:00
Owen Anderson
0ced13ccd9
This condition got inverted accidentally.
...
llvm-svn: 50473
2008-04-30 07:16:33 +00:00
Chris Lattner
2dc4426675
move lowering of llvm.memset -> store from simplify libcalls
...
to instcombine.
llvm-svn: 50472
2008-04-30 06:39:11 +00:00
Chris Lattner
438e35c4d1
use string length computation to generalize several xforms.
...
llvm-svn: 50464
2008-04-30 03:07:53 +00:00
Owen Anderson
ad5367f8ed
Revert r50441. The original code was correct. Add some more comments so that I don't make the same mistake in the future.
...
llvm-svn: 50446
2008-04-29 21:51:00 +00:00
Owen Anderson
ff7d7b18e5
Fix a bug in memcpyopt where the memcpy-memcpy transform was never being applied because
...
we were checking for it in the wrong order. This caused a miscompilation because the
return slot optimization assumes that the call it is dealing with is NOT a memcpy.
llvm-svn: 50444
2008-04-29 21:26:06 +00:00
Owen Anderson
f07de734cf
We should be returning true here since we've changed the function.
...
llvm-svn: 50442
2008-04-29 21:02:46 +00:00
Owen Anderson
e674600266
A lot of cleanups and documentation improvements, as well as a few corner case fixes. Most
...
of this was suggested by Chris.
llvm-svn: 50441
2008-04-29 20:59:33 +00:00
Owen Anderson
2306a1e098
Rename DeadLoopElimination to LoopDeletion, part 2.
...
llvm-svn: 50437
2008-04-29 20:06:54 +00:00
Owen Anderson
e9f05bd1f0
Rename DeadLoopElimination to LoopDeletion, part one.
...
llvm-svn: 50436
2008-04-29 19:58:07 +00:00
Chris Lattner
d9e3b5c5bd
don't eliminate load from volatile value on paths where the load is dead.
...
This fixes the second half of PR2262
llvm-svn: 50430
2008-04-29 17:28:22 +00:00
Chris Lattner
9233c124c9
fix a subtle volatile handling bug.
...
llvm-svn: 50428
2008-04-29 17:13:43 +00:00
Chris Lattner
92f4702254
Implement more aggressive support for analyzing string length. This
...
generalizes the previous code to handle the case when the string is not
an immediate to the strlen call (for example, crazy stuff like
strlen(c ? "foo" : "bart"+1) -> 3). This implements
gcc.c-torture/execute/builtins/strlen-2.c. I will generalize other
cases in simplifylibcalls to use the same routine later.
llvm-svn: 50408
2008-04-29 06:56:02 +00:00
Owen Anderson
304ef22f6e
Clarify what we mean by a dead loop.
...
llvm-svn: 50406
2008-04-29 06:34:55 +00:00
Chris Lattner
e331a65c79
don't delete the last store to an alloca if the store is volatile.
...
llvm-svn: 50390
2008-04-29 04:58:38 +00:00
Owen Anderson
586216e5bb
Add some more comments.
...
llvm-svn: 50384
2008-04-29 00:45:15 +00:00
Owen Anderson
41377175d3
Remove debugging code.
...
llvm-svn: 50383
2008-04-29 00:39:24 +00:00
Owen Anderson
94ad702412
Add dead loop elimination, which removes dead loops for which we can compute
...
the trip count.
llvm-svn: 50382
2008-04-29 00:38:34 +00:00
Dan Gohman
8cb19d967f
Fix DSE to not eliminate volatile loads with no uses.
...
llvm-svn: 50370
2008-04-28 19:51:27 +00:00
Dan Gohman
72ec3f4562
Teach InstCombine's ComputeMaskedBits what SelectionDAG's
...
ComputeMaskedBits knows about cttz, ctlz, and ctpop. Teach
SelectionDAG's ComputeMaskedBits what InstCombine's knows
about SRem. And teach them both some things about high bits
in Mul, UDiv, URem, and Sub. This allows instcombine and
dagcombine to eliminate sign-extension operations in
several new cases.
llvm-svn: 50358
2008-04-28 17:02:21 +00:00
Chris Lattner
8be72700b8
Fix PR2256, yet another miscompilation in simplifycfg of i
...
multiple return values.
Bill, please pull this into Tak.
llvm-svn: 50332
2008-04-28 00:19:07 +00:00
Chris Lattner
2237973438
Implement a signficant optimization for inline asm:
...
When choosing between constraints with multiple options,
like "ir", test to see if we can use the 'i' constraint and
go with that if possible. This produces more optimal ASM in
all cases (sparing a register and an instruction to load it),
and fixes inline asm like this:
void test () {
asm volatile (" %c0 %1 " : : "imr" (42), "imr"(14));
}
Previously we would dump "42" into a memory location (which
is ok for the 'm' constraint) which would cause a problem
because the 'c' modifier is not valid on memory operands.
Isn't it great how inline asm turns 'missed optimization'
into 'compile failed'??
Incidentally, this was the todo in
PowerPC/2007-04-24-InlineAsm-I-Modifier.ll
Please do NOT pull this into Tak.
llvm-svn: 50315
2008-04-27 00:37:18 +00:00
Chris Lattner
4793515a9c
Move a bunch of inline asm code out of line.
...
llvm-svn: 50313
2008-04-27 00:09:47 +00:00
Chris Lattner
67ca6f6347
When SRoA'ing a global variable, make sure the new globals get the
...
appropriate alignment. This fixes a miscompilation of 252.eon on
x86-64 (rdar://5891920).
Bill, please pull this into Tak.
llvm-svn: 50308
2008-04-26 07:40:11 +00:00
Dale Johannesen
0d1d3df564
change comments per review
...
llvm-svn: 50300
2008-04-25 21:16:07 +00:00
Dan Gohman
ca95a5f49f
Remove the code from CodeGenPrepare that moved getresult instructions
...
to the block that defines their operands. This doesn't work in the
case that the operand is an invoke, because invoke is a terminator
and must be the last instruction in a block.
Replace it with support in SelectionDAGISel for copying struct values
into sequences of virtual registers.
llvm-svn: 50279
2008-04-25 18:27:55 +00:00
Nate Begeman
ca270ad96f
Feedback from chris
...
llvm-svn: 50271
2008-04-25 17:45:52 +00:00
Nick Lewycky
4d43d3c72c
Remove 'unwinds to' support from mainline. This patch undoes r47802 r47989
...
r48047 r48084 r48085 r48086 r48088 r48096 r48099 r48109 and r48123.
llvm-svn: 50265
2008-04-25 16:53:59 +00:00
Nate Begeman
6fed3b2038
Teach the PruningFunctionCloner how to look through loads with
...
ConstantExpression GEPs pointing into constant globals.
llvm-svn: 50256
2008-04-25 06:37:06 +00:00
Chris Lattner
f7de528463
Don't infininitely thread branches when a threaded edge
...
goes back to the block, e.g.:
Threading edge through bool from 'bb37.us.thread3829' to 'bb37.us' with cost: 1, across block:
bb37.us: ; preds = %bb37.us.thread3829, %bb37.us, %bb33
%D1361.1.us = phi i32 [ %tmp36, %bb33 ], [ %D1361.1.us, %bb37.us ], [ 0, %bb37.us.thread3829 ] ; <i32> [#uses=2]
%tmp39.us = icmp eq i32 %D1361.1.us, 0 ; <i1> [#uses=1]
br i1 %tmp39.us, label %bb37.us, label %bb42.us
llvm-svn: 50251
2008-04-25 04:12:29 +00:00
Evan Cheng
608eeef5ce
Adjust inline cost computation to be less aggressive.
...
llvm-svn: 50222
2008-04-24 18:42:47 +00:00
Chris Lattner
97951ac580
code restructuring, not functionality change.
...
llvm-svn: 50203
2008-04-24 00:21:50 +00:00
Chris Lattner
12f1e007f7
Don't replace multiple result of calls with undef,
...
sccp tracks getresult values, not call values in this
case.
llvm-svn: 50202
2008-04-24 00:19:54 +00:00
Chris Lattner
769203cb03
code cleanup, no functionality change.
...
llvm-svn: 50201
2008-04-24 00:16:28 +00:00
Chris Lattner
86bbf338e5
Split some code out of the main SimplifyCFG loop into its own function.
...
Fix said code to handle merging return instructions together correctly
when handling multiple return values.
llvm-svn: 50199
2008-04-24 00:01:19 +00:00
Devang Patel
8f83081fea
Check type instead of no. of operands.
...
llvm-svn: 50179
2008-04-23 20:18:29 +00:00
Dale Johannesen
f6e15a4774
Rewrite previous patch to suit Chris's preference.
...
llvm-svn: 50174
2008-04-23 18:34:37 +00:00
Chris Lattner
a82d691caa
simplify code for propagation of constant arguments into
...
callees.
llvm-svn: 50142
2008-04-23 06:16:27 +00:00
Chris Lattner
5f1802cfdf
Fix a number of bugs in ipconstantprop, simplify the code, fit in 80 cols,
...
fix read after free bug (PR2238).
llvm-svn: 50141
2008-04-23 05:59:23 +00:00
Chris Lattner
5a58a4dc6d
Rewrite multiple return value handling in SCCP. Before, the -sccp pass
...
would turn every getresult instruction into undef. This helps with
rdar://5778210
llvm-svn: 50140
2008-04-23 05:38:20 +00:00
Dale Johannesen
493527d8c9
Do not change the type of a ByVal argument to a
...
type of a different size.
llvm-svn: 50121
2008-04-23 01:03:05 +00:00
Evan Cheng
1c89ca7295
Don't do: "(X & 4) >> 1 == 2 --> (X & 4) == 4" if there are more than one uses of the shift result.
...
llvm-svn: 50118
2008-04-23 00:38:06 +00:00
Chris Lattner
37e9c187b0
Start doing the significantly useful part of jump threading: handle cases
...
where a comparison has a phi input and that phi is a constant. For example,
stuff like:
Threading edge through bool from 'bb2149' to 'bb2231' with cost: 1, across block:
bb2237: ; preds = %bb2231, %bb2149
%tmp2328.rle = phi i32 [ %tmp2232, %bb2231 ], [ %tmp2232439, %bb2149 ] ; <i32> [#uses=2]
%done.0 = phi i32 [ %done.2, %bb2231 ], [ 0, %bb2149 ] ; <i32> [#uses=1]
%tmp2239 = icmp eq i32 %done.0, 0 ; <i1> [#uses=1]
br i1 %tmp2239, label %bb2231, label %bb2327
or
bb38.i298: ; preds = %bb33.i295, %bb1693
%tmp39.i296.rle = phi %struct.ibox* [ null, %bb1693 ], [ %tmp39.i296.rle1109, %bb33.i295 ] ; <%struct.ibox*> [#uses=2]
%minspan.1.i291.reg2mem.1 = phi i32 [ 32000, %bb1693 ], [ %minspan.0.i288, %bb33.i295 ] ; <i32> [#uses=1]
%tmp40.i297 = icmp eq %struct.ibox* %tmp39.i296.rle, null ; <i1> [#uses=1]
br i1 %tmp40.i297, label %implfeeds.exit311, label %bb43.i301
This triggers thousands of times in spec.
llvm-svn: 50110
2008-04-22 21:40:39 +00:00
Chris Lattner
d5425e8f8d
Dig through multiple levels of AND to thread jumps if needed.
...
llvm-svn: 50106
2008-04-22 20:46:09 +00:00
Chris Lattner
3df4c15dc7
Teach jump threading to thread through blocks like:
...
br (and X, phi(Y, Z, false)), label L1, label L2
This triggers once on 252.eon and 6 times on 176.gcc. Blocks
in question often look like this:
bb262: ; preds = %bb261, %bb248
%iftmp.251.0 = phi i1 [ true, %bb261 ], [ false, %bb248 ] ; <i1> [#uses=4]
%tmp270 = icmp eq %struct.rtx_def* %tmp.0.i, null ; <i1> [#uses=1]
%bothcond = or i1 %iftmp.251.0, %tmp270 ; <i1> [#uses=1]
br i1 %bothcond, label %bb288, label %bb273
In this case, it is clear that it doesn't matter if tmp.0.i is null when coming from bb261. When coming from bb248, it is all that matters.
Another random example:
check_asm_operands.exit: ; preds = %check_asm_operands.exit.thr_comm, %bb30.i, %bb12.i, %bb6.i413
%tmp.0.i420 = phi i1 [ true, %bb6.i413 ], [ true, %bb12.i ], [ true, %bb30.i ], [ false, %check_asm_operands.exit.thr_comm ; <i1> [#uses=1]
call void @llvm.stackrestore( i8* %savedstack ) nounwind
%tmp4389 = icmp eq i32 %added_sets_1.0, 0 ; <i1> [#uses=1]
%tmp4394 = icmp eq i32 %added_sets_2.0, 0 ; <i1> [#uses=1]
%bothcond80 = and i1 %tmp4389, %tmp4394 ; <i1> [#uses=1]
%bothcond81 = and i1 %bothcond80, %tmp.0.i420 ; <i1> [#uses=1]
br i1 %bothcond81, label %bb4398, label %bb4397
Here is the case from 252.eon:
bb290.i.i: ; preds = %bb23.i57.i.i, %bb8.i39.i.i, %bb100.i.i, %bb100.i.i, %bb85.i.i110
%myEOF.1.i.i = phi i1 [ true, %bb100.i.i ], [ true, %bb100.i.i ], [ true, %bb85.i.i110 ], [ true, %bb8.i39.i.i ], [ false, %bb23.i57.i.i ] ; <i1> [#uses=2]
%i.4.i.i = phi i32 [ %i.1.i.i, %bb85.i.i110 ], [ %i.0.i.i, %bb100.i.i ], [ %i.0.i.i, %bb100.i.i ], [ %i.3.i.i, %bb8.i39.i.i ], [ %i.3.i.i, %bb23.i57.i.i ] ; <i32> [#uses=3]
%tmp292.i.i = load i8* %tmp16.i.i100, align 1 ; <i8> [#uses=1]
%tmp293.not.i.i = icmp ne i8 %tmp292.i.i, 0 ; <i1> [#uses=1]
%bothcond.i.i = and i1 %tmp293.not.i.i, %myEOF.1.i.i ; <i1> [#uses=1]
br i1 %bothcond.i.i, label %bb202.i.i, label %bb301.i.i
Factoring out 3 common predecessors.
On the path from any blocks other than bb23.i57.i.i, the load and compare
are dead.
llvm-svn: 50096
2008-04-22 07:05:46 +00:00
Chris Lattner
e369c35a84
refactor some code, no functionality change.
...
llvm-svn: 50094
2008-04-22 06:36:15 +00:00
Chris Lattner
8fb13cbe4e
remove dead code.
...
llvm-svn: 50080
2008-04-22 03:21:48 +00:00
Chris Lattner
c3a439351c
optimize "p != gep p, ..." better. This allows us to compile
...
getelementptr-seteq.ll into:
define i1 @test(i64 %X, %S* %P) {
%C = icmp eq i64 %X, -1 ; <i1> [#uses=1]
ret i1 %C
}
instead of:
define i1 @test(i64 %X, %S* %P) {
%A.idx.mask = and i64 %X, 4611686018427387903 ; <i64> [#uses=1]
%C = icmp eq i64 %A.idx.mask, 4611686018427387903 ; <i1> [#uses=1]
ret i1 %C
}
And fixes the second half of PR2235. This speeds up the insertion sort
case by 45%, from 1.12s to 0.77s. In practice, this will significantly
speed up for loops structured like:
for (double *P = Base + N; P != Base; --P)
...
Which happens frequently for C++ iterators.
llvm-svn: 50079
2008-04-22 02:53:33 +00:00
Chris Lattner
bab7bec9c8
fix grammar-o, thanks to Duncan for noticing.
...
llvm-svn: 50047
2008-04-21 18:25:01 +00:00
Owen Anderson
a5b96ecef9
Remove unneeded #include's.
...
llvm-svn: 50035
2008-04-21 07:47:38 +00:00
Owen Anderson
6a7355caa2
Refactor memcpyopt based on Chris' suggestions. Consolidate several functions
...
and simplify code that was fallout from the separation of memcpyopt and gvn.
llvm-svn: 50034
2008-04-21 07:45:10 +00:00
Chris Lattner
ad0d42ba15
don't assume that the argument passed to fprintf("%s" is a string. This
...
fixes a crash in opt on 433.milc.
llvm-svn: 50023
2008-04-21 03:18:33 +00:00
Chris Lattner
f6236cc2e9
Use the new SplitBlockPredecessors to implement a todo.
...
llvm-svn: 50022
2008-04-21 02:57:57 +00:00
Chris Lattner
a5b11705b6
Move SplitBlockPredecessors out of loopsimplify into BasicBlockUtils.h
...
as a global helper function. At the same type, switch it from taking
a vector of predecessors to an arbitrary sequential input. This allows
us to switch LoopSimplify to use a SmallVector for various temporary
vectors that it passed into SplitBlockPredecessors.
llvm-svn: 50020
2008-04-21 01:28:02 +00:00
Chris Lattner
d418b06abf
Move domtree/frontier updating earlier, allowing us to use it to update phi
...
nodes, removing a hack.
llvm-svn: 50019
2008-04-21 01:05:08 +00:00
Chris Lattner
96e9e22269
Factor dominator tree and frontier updating into SplitBlockPredecessors
...
instead of doing it after every call.
llvm-svn: 50018
2008-04-21 00:54:38 +00:00
Chris Lattner
559c867ece
fit some more code in 80 cols.
...
llvm-svn: 50016
2008-04-21 00:25:49 +00:00
Chris Lattner
aca912d793
simplify code, fit in 80 cols.
...
llvm-svn: 50015
2008-04-21 00:23:14 +00:00
Chris Lattner
38806c3e9c
fit in 80 cols
...
llvm-svn: 50014
2008-04-21 00:19:16 +00:00
Chris Lattner
ff1c6e388c
finish the first cut of a jump threading pass implementation.
...
llvm-svn: 50006
2008-04-20 22:39:42 +00:00
Chris Lattner
567166c0a8
replace a slow and verbose version of Instruction::isUsedOutsideOfBlock with
...
a call to Instruction::isUsedOutsideOfBlock.
llvm-svn: 50005
2008-04-20 22:18:22 +00:00
Chris Lattner
9c1f1a82bf
we can only thread blocks when there is a pred we can determine the succ of.
...
llvm-svn: 50003
2008-04-20 21:18:09 +00:00
Chris Lattner
2115722ffa
improve comments, infrastructure, and add some validity checks for threading.
...
Add a cost function.
llvm-svn: 50002
2008-04-20 21:13:06 +00:00
Chris Lattner
b3b6007c8b
Add a new Jump Threading pass, which will handle cases
...
such as those in PR2235. Right now the pass is not very
effective. :)
llvm-svn: 50000
2008-04-20 20:35:01 +00:00