Nick Lewycky
035fe6f716
Peer through sext/zext when looking for not(cmp).
...
llvm-svn: 51819
2008-05-31 19:01:33 +00:00
Nick Lewycky
26b8cd84b3
Add more i1 optimizations. add, sub, mul, s/udiv on i1 are now simplified away.
...
llvm-svn: 51817
2008-05-31 17:59:52 +00:00
Nick Lewycky
df9242a833
Adding i1 is always Xor.
...
llvm-svn: 51816
2008-05-31 17:10:28 +00:00
Dan Gohman
86ff8536f9
const-ify getOpcode.
...
llvm-svn: 51698
2008-05-29 19:53:46 +00:00
Duncan Sands
9e064a2180
Add a newline at the end of this file.
...
llvm-svn: 51680
2008-05-29 14:38:23 +00:00
Owen Anderson
7686b555e2
Replace the old ADCE implementation with a new one that more simply solves
...
the one case that ADCE catches that normal DCE doesn't: non-induction variable
loop computations.
This implementation handles this problem without using postdominators.
llvm-svn: 51668
2008-05-29 08:45:13 +00:00
Owen Anderson
f4aece5976
Remove debugging code.
...
llvm-svn: 51666
2008-05-29 08:15:48 +00:00
Chris Lattner
ecdefb5df7
Implement PR2370: memmove(x,x,size) -> noop.
...
llvm-svn: 51636
2008-05-28 05:30:41 +00:00
Duncan Sands
698348dfac
Fix some constructs that gcc-4.4 warns about.
...
llvm-svn: 51591
2008-05-27 11:50:51 +00:00
Nick Lewycky
3ebe82b57a
InequalityGraph::node() can create new nodes, invalidating iterators across
...
the set of nodes. Fix makeEqual to handle this by creating the new node first
then iterating across them second.
llvm-svn: 51573
2008-05-27 00:59:05 +00:00
Nick Lewycky
6be65d2a84
Grammaro.
...
llvm-svn: 51572
2008-05-26 22:49:36 +00:00
Nick Lewycky
f6ccd2580c
"ret (constexpr)" can't be folded into a Constant. Add a method to
...
Analysis/ConstantFolding to fold ConstantExpr's, then make instcombine use it
to try to use targetdata to fold constant expressions on void instructions.
Also extend the icmp(inttoptr, inttoptr) folding to handle the case where
int size != ptr size.
llvm-svn: 51559
2008-05-25 20:56:15 +00:00
Chris Lattner
87a099a057
Fix a serious brain-o. Obviously no-one reviewed my patch :(
...
This fixes PR2359
llvm-svn: 51536
2008-05-24 04:06:28 +00:00
Chris Lattner
5c207c83c6
Fix PR2358 by resolving calls with undef arguments to overdefined.
...
llvm-svn: 51535
2008-05-24 03:59:33 +00:00
Evan Cheng
02912418f1
Remove x86.sse2.loadh.pd and x86.sse2.loadl.pd. These will be lowered into load and shuffle instructions.
...
llvm-svn: 51521
2008-05-24 00:07:06 +00:00
Dan Gohman
f96e1371e8
Tidy up BasicBlock::getFirstNonPHI, and change a bunch of places to
...
use it instead of duplicating its functionality.
llvm-svn: 51499
2008-05-23 21:05:58 +00:00
Matthijs Kooijman
f52b23c0eb
Replace some weird usage of UserOp1 introduced in r49492 by a plain if.
...
llvm-svn: 51482
2008-05-23 16:17:48 +00:00
Nick Lewycky
3bf5512d87
Constant integer vectors may also be negated.
...
llvm-svn: 51476
2008-05-23 04:54:45 +00:00
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
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
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