Dan Gohman
1f1ebc5389
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
50061675c5
Canonicalize sext(i1) to i1?-1:0, and update various instcombine
...
optimizations accordingly.
llvm-svn: 58457
2008-10-30 20:40:10 +00:00
Daniel Dunbar
097da598fb
Add InlineCost class for represent the estimated cost of inlining a
...
function.
- This explicitly models the costs for functions which should
"always" or "never" be inlined. This fixes bugs where such costs
were not previously respected.
llvm-svn: 58450
2008-10-30 19:26:59 +00:00
Chris Lattner
4af91a146a
Fix PR2967 by not deleting volatile load/stores that occur before unreachable.
...
I don't really see this as being needed, but there is little harm from doing
it.
llvm-svn: 58385
2008-10-29 17:46:26 +00:00
Dan Gohman
3ceee36545
(A & sext(C)) | (B & ~sext(C) -> C ? A : B
...
llvm-svn: 58351
2008-10-28 22:38:57 +00:00
Chris Lattner
a57ac16183
no need to print output
...
llvm-svn: 58228
2008-10-27 06:56:35 +00:00
Nick Lewycky
44356e13da
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
Chris Lattner
3048ccc1f9
apply Eli's patch for PR2165 and provide a testcase.
...
llvm-svn: 57625
2008-10-16 05:26:51 +00:00
Dan Gohman
6f40163d83
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
591baeed7c
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
778b47e6c0
- 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
91528965e7
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
7a61ef92f5
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
Devang Patel
255fee3bce
Check loop exit predicate properly while eliminating one iteration loop.
...
This patch fixes PR 2869
llvm-svn: 57369
2008-10-10 22:02:57 +00:00
Devang Patel
378c8633e5
Fix typo, fix PR 2865.
...
llvm-svn: 57221
2008-10-06 23:22:54 +00:00
Matthijs Kooijman
12cd5d041d
Allow scalarrepl to treat an all-zero GEP just as bitcast.
...
This includes not marking a GEP involving a vector as unsafe, but only when it
has all zero indices. This allows scalarrepl to work in a few more cases.
llvm-svn: 57177
2008-10-06 16:23:31 +00:00
Chris Lattner
107e8f8b60
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
Duncan Sands
e22385630e
Ignore loads from and stores to local memory (i.e. allocas)
...
when deciding whether to mark a function readnone/readonly.
Since the pass is currently run before SROA, this may be
quite helpful. Requested by Chris on IRC.
llvm-svn: 57050
2008-10-04 13:24:24 +00:00
Nick Lewycky
53e751fcba
Allow the construction of SCEVs with SCEVCouldNotCompute operands, by
...
implementing folding. Fixes PR2857.
llvm-svn: 57049
2008-10-04 11:19:07 +00:00
Devang Patel
55401473f9
Nick Lewycky's patch.
...
While hosting instruction check PHI node.
llvm-svn: 57025
2008-10-03 18:57:37 +00:00
Nick Lewycky
9e918179c8
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
Devang Patel
7536edca09
Support inreg, zext and sext as return value attributes.
...
llvm-svn: 56801
2008-09-29 20:49:50 +00:00
Matthijs Kooijman
9fb8d5f5b1
Add a testcase showing that scalarrepl supports first class structs.
...
I originally made this script to show that scalarrepl didn't support them, but
it turned out it does. Better to still add the testcase then.
llvm-svn: 56781
2008-09-29 10:42:13 +00:00
Devang Patel
47a504c87c
Implement function notes as function attributes.
...
llvm-svn: 56716
2008-09-26 23:51:19 +00:00
Duncan Sands
2c9f6ab06d
Rationalize the names of passes that print information:
...
-callgraph => print-callgraph
-callscc => print-callgraph-sccs
-cfgscc => print-cfg-sccs
-externalfnconstants => print-externalfnconstants
-print => print-function
-print-alias-sets (no change)
-print-callgraph => dot-callgraph
-print-cfg => dot-cfg
-print-cfg-only => dot-cfg-only
-print-dom-info (no change)
-printm => print-module
-printusedtypes => print-used-types
llvm-svn: 56487
2008-09-23 12:47:39 +00:00
Duncan Sands
df9829409c
Add test for improvement of readonly to readnone,
...
and non-demotion of readnone to readonly.
llvm-svn: 56344
2008-09-19 09:20:05 +00:00
Duncan Sands
6c31b40cef
Turn on these tests!
...
llvm-svn: 56343
2008-09-19 09:16:32 +00:00
Duncan Sands
c2ff9ca568
Add a new pass AddReadAttrs which works out which functions
...
can get the readnone/readonly attributes, and gives them it.
The plan is to remove markmodref (which did the same thing
by querying GlobalsModRef) and delete the analogous
functionality from GlobalsModRef.
llvm-svn: 56341
2008-09-19 08:17:05 +00:00
Duncan Sands
bb48df5839
Test the callgraph directly for the missing edge.
...
llvm-svn: 56338
2008-09-19 08:01:57 +00:00
Devang Patel
1e7ddf5d31
splitLoop does not handle split condition EQ.
...
Fixes PR 2805
llvm-svn: 56321
2008-09-18 23:45:14 +00:00
Devang Patel
88efee2dcc
Do not hoist instruction above branch condition. The instruction may use branch condition.
...
llvm-svn: 56286
2008-09-17 18:21:49 +00:00
Devang Patel
50c22bf69b
Do not ignore iv uses outside the loop.
...
This one slipped through cracks very well.
llvm-svn: 56284
2008-09-17 17:53:47 +00:00
Dan Gohman
c598e29a1c
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
0b6d3a9a9b
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
5e154a591d
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
ebfb483309
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
Devang Patel
ed0ea8049f
Remove.
...
llvm-svn: 56018
2008-09-09 21:41:34 +00:00
Devang Patel
7365754925
if loop induction variable is always sign or zero extended then
...
extend the type of induction variable.
llvm-svn: 56017
2008-09-09 21:41:07 +00:00
Devang Patel
36ad68421e
fix overflow check.
...
llvm-svn: 56011
2008-09-09 20:54:34 +00:00
Anton Korobeynikov
4676c09dc8
Resolve aliases, when possible
...
llvm-svn: 56001
2008-09-09 19:04:59 +00:00
Dan Gohman
28c911b79b
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
Devang Patel
b6380f607d
Fix simplifycfg crash in handing block merge.
...
llvm-svn: 55971
2008-09-09 01:06:56 +00:00
Devang Patel
c60c8e35eb
xfail
...
llvm-svn: 55914
2008-09-08 16:24:30 +00:00
Duncan Sands
62431a29a5
Update the callgraph correctly in ArgumentPromotion.
...
llvm-svn: 55895
2008-09-08 11:07:35 +00:00
Duncan Sands
c4ec7871bf
When PruneEH turned an invoke into an ordinary
...
call (thus changing the call site) it didn't
inform the callgraph about this. But the
call site does matter - as shown by the testcase,
the callgraph become invalid after the inliner
ran (with an edge between two functions simply
missing), resulting in wrong deductions by
GlobalsModRef.
llvm-svn: 55872
2008-09-06 17:19:29 +00:00
Nick Lewycky
57cebeaeba
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
Devang Patel
4dfecae8fe
Check iteration count.
...
llvm-svn: 55680
2008-09-03 00:10:56 +00:00
Devang Patel
a1e2066b1d
If all IV uses are extending integer IV then change the type of IV itself, if possible.
...
llvm-svn: 55674
2008-09-02 22:18:08 +00:00
Devang Patel
cda9086d29
respect inline=never and inline=always notes.
...
llvm-svn: 55673
2008-09-02 22:16:13 +00:00
Devang Patel
211c05f7a3
If IV is used in a int-to-float cast inside the loop then try to eliminate the cast operation.
...
llvm-svn: 55374
2008-08-26 17:57:54 +00:00
Chris Lattner
72ee6ebb0a
Fix PR2423 by checking all indices for out of range access, not only
...
indices that start with an array subscript. x->field[10000] is just
as bad as (*X)[14][10000].
llvm-svn: 55226
2008-08-23 05:21:06 +00:00
Nick Lewycky
7b87c4d8a4
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
Bill Wendling
98fb8113e8
XFAIL this test for now.
...
llvm-svn: 54929
2008-08-18 18:29:54 +00:00
Nick Lewycky
30a0ad8900
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
Evan Cheng
5ebbd688ec
Didn't mean to change this.
...
llvm-svn: 54904
2008-08-17 19:25:28 +00:00
Evan Cheng
6534c78383
Fix a (u)comiss intrinsic lowering bug. It was using anyext which can return junk in higher bits. Patch by Nate Begeman.
...
llvm-svn: 54903
2008-08-17 19:22:34 +00:00
Nick Lewycky
205be593b8
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
42c1d6c7b9
Remove GCSE and LoadVN from the testsuite.
...
llvm-svn: 54832
2008-08-16 00:00:54 +00:00
Devang Patel
a8e9ee0529
Reapply 54786. Add overflow and number of mantissa bits checks.
...
llvm-svn: 54821
2008-08-15 21:21:34 +00:00
Evan Cheng
b2e1459e48
Revert 54786. It's not checking for overflows, etc.
...
llvm-svn: 54813
2008-08-15 08:12:11 +00:00
Devang Patel
67f9b08a91
If IV is used in a int-to-float cast inside the loop then try to eliminate the cast opeation.
...
llvm-svn: 54786
2008-08-14 20:58:31 +00:00
Dan Gohman
db5b503d60
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
Dan Gohman
374d9328b7
Fix SCCP's handling of struct value loads and stores. SCCP doesn't
...
track individual leaf values in such cases, so it needs to treat
struct values as normal values in this case.
llvm-svn: 54760
2008-08-13 21:22:48 +00:00
Devang Patel
a82e51a430
Check sign to detect overflow before changing compare stride.
...
llvm-svn: 54710
2008-08-13 02:05:14 +00:00
Chris Lattner
ae09ade343
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
Matthijs Kooijman
cb2af3cd69
Add a basic test for the SRETPromotion pass.
...
llvm-svn: 54466
2008-08-07 15:55:18 +00:00
Matthijs Kooijman
7f32ea1320
Move two tests from SRETPromotion to Inline, since they only call opt -inline.
...
llvm-svn: 54465
2008-08-07 15:36:46 +00:00
Dan Gohman
4ad77e1ca2
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
Evan Cheng
cbb33fb6e8
PR2535, not PR2355.
...
llvm-svn: 54416
2008-08-06 18:06:48 +00:00
Evan Cheng
c5cc2cb4aa
Fix PR2355: bug in ChangeCompareStride. When the loop termination compare is the only use of its iv stride, the stride can be eliminated by moving it to another stride. If the scale is negative, swap the predicate instead of using a inverse predicate.
...
llvm-svn: 54415
2008-08-06 18:04:43 +00:00
Chris Lattner
55b99a6739
optimize a common idiom generated by clang for bitfield access, PR2638.
...
llvm-svn: 54408
2008-08-06 07:35:52 +00:00
Chris Lattner
cae04940bd
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
0bf3c812d2
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
1854852a75
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
aea14c2dfe
Add default architecture.
...
llvm-svn: 54384
2008-08-05 23:36:00 +00:00
Bill Wendling
f69c83e554
Testcase for PR2629.
...
llvm-svn: 54377
2008-08-05 22:23:59 +00:00
Bill Wendling
3882f060ef
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
Matthijs Kooijman
7199907f50
Add -unroll-allow-partial command line option that enabled the loop unroller to
...
partially unroll a loop when fully unrolling would not fit under the threshold.
Patch by Mikael Lepistö.
llvm-svn: 54160
2008-07-29 13:21:23 +00:00
Matthijs Kooijman
77948dbbc2
Restructure ArgumentPromotion a bit. Instead of just having a single boolean
...
that says "unconditional loads from this argument are safe", we now keep track
of the safety per set of indices from which loads happen. This prevents
ArgPromotion from promoting loads that aren't really valid. As an added effect,
this will now disregard the the type of the indices passed to a GEP, so
"load GEP %A, i32 1" and "load GEP %A, i64 1" will result in a single argument,
not two.
This fixes PR2598, for which a testcase has been added as well.
llvm-svn: 54159
2008-07-29 10:00:13 +00:00
Owen Anderson
4d84a90fa9
Add support for eliminating stores that store the same value that was just loaded.
...
This fixes PR2599.
llvm-svn: 54133
2008-07-28 16:14:26 +00:00
Dan Gohman
1ecbcecdf3
Put the LICM of constant GlobalVariables, introduced in r53945, under a
...
command-line option, and disable it by default. It introduced performance
regressions because CodeGen is currently not able to remat such loads.
llvm-svn: 53997
2008-07-24 23:57:25 +00:00
Chris Lattner
8eb899ecbc
"Allow LICM to sink or lift loads from constant memory. Also add a test
...
case for this.
This allows instructions like loads from global variables declared to
be constant to be moved out of loops."
Patch by Stefanus Du Toit!
llvm-svn: 53945
2008-07-23 05:06:28 +00:00
Dan Gohman
6564581be0
Enable first-class aggregates support.
...
Remove the GetResultInst instruction. It is still accepted in LLVM assembly
and bitcode, where it is now auto-upgraded to ExtractValueInst. Also, remove
support for return instructions with multiple values. These are auto-upgraded
to use InsertValueInst instructions.
The IRBuilder still accepts multiple-value returns, and auto-upgrades them
to InsertValueInst instructions.
llvm-svn: 53941
2008-07-23 00:34:11 +00:00
Dan Gohman
693339b859
Add the PR number to the test.
...
llvm-svn: 53880
2008-07-21 21:50:25 +00:00
Dan Gohman
8f7b6c8113
Fix a bug in LSR's dead-PHI cleanup. If a PHI has a def-use chain that
...
leads into a cycle involving a different PHI, LSR got stuck running
around that cycle looking for the original PHI. To avoid this, keep
track of visited PHIs and stop searching if we see one more than once.
This fixes PR2570.
llvm-svn: 53879
2008-07-21 21:45:02 +00:00
Matthijs Kooijman
5ec5e264e4
Make GlobalOpt preserve address spaces when scalar replacing aggregate globals.
...
llvm-svn: 53716
2008-07-17 11:59:53 +00:00
Chris Lattner
eccd57d118
Fix PR2553
...
llvm-svn: 53715
2008-07-17 06:07:20 +00:00
Matthijs Kooijman
c05651e3ce
Add a few cases to instcombine's extractvalue testcase.
...
llvm-svn: 53675
2008-07-16 12:57:25 +00:00
Matthijs Kooijman
0625e0fda6
Un-XFAIL multdeadretval, since instcombine now properly handles the mess deadargelim leaves behind :-)
...
llvm-svn: 53674
2008-07-16 12:56:52 +00:00
Evan Cheng
7218339189
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
Matthijs Kooijman
45140a0497
XFAIL the multdeadretval test for now, I will be fixing instcombine to make it work again tomorrow.
...
llvm-svn: 53614
2008-07-15 16:05:09 +00:00
Matthijs Kooijman
48fd953b49
Remove a few tests which no longer hold for deadargelim (since it is now
...
allowed to canonicalize return values).
Add a test that checks if return value and function attributes are not removed.
llvm-svn: 53612
2008-07-15 14:57:01 +00:00
Matthijs Kooijman
21162f1db9
Add a testcase for the canonicalizations now performed by deadargelim.
...
llvm-svn: 53611
2008-07-15 14:42:58 +00:00
Matthijs Kooijman
f940585c1c
Make deadargelim a bit less smart, so it doesn't choke on nested structs as
...
return values that are still (partially) live. Instead of updating all uses of
a call instruction after removing some elements, it now just rebuilds the
original struct (With undef gaps where the unused values were) and leaves it to
instcombine to clean this up.
The added testcase still fails currently, but this is due to instcombine which
isn't good enough yet. I will fix that part next.
llvm-svn: 53608
2008-07-15 14:03:10 +00:00
Matthijs Kooijman
02ffbaf305
Fix typo.
...
llvm-svn: 53605
2008-07-15 13:15:10 +00:00
Chris Lattner
14faada3a3
Fix PR2506 by being a bit more careful about reverse fact propagation when
...
disproving a condition. This actually compiles the existing testcase
(udiv_select_to_select_shift) to:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%divisor1.t = lshr i64 %X, 3 ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %divisor1.t, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
instead of:
define i64 @test(i64 %X, i1 %Cond) {
entry:
%quotient1.v = select i1 %Cond, i64 3, i64 4 ; <i64> [#uses=1]
%quotient1 = lshr i64 %X, %quotient1.v ; <i64> [#uses=1]
%quotient2 = lshr i64 %X, 3 ; <i64> [#uses=1]
%sum = add i64 %quotient1, %quotient2 ; <i64> [#uses=1]
ret i64 %sum
}
llvm-svn: 53534
2008-07-14 00:15:52 +00:00
Chris Lattner
3444f4d4c4
Fix mishandling of the infinite loop case when merging two blocks. This
...
fixes PR2540.
llvm-svn: 53533
2008-07-13 22:23:11 +00:00
Nick Lewycky
3fb5816774
Enhance analysis of srem.
...
Remove dead code analyzing urem. 'urem' of power-of-2 is canonicalized to an
'and' instruction.
llvm-svn: 53506
2008-07-12 05:04:38 +00:00
Nick Lewycky
8cd0f2058e
Add another optimization from PR2330. Also catch some missing cases that are
...
similar.
llvm-svn: 53451
2008-07-11 07:20:53 +00:00
Chris Lattner
16b8ae98c1
Fix folding of icmp's of i1 where the comparison is signed. The code
...
was using the algorithm for folding unsigned comparisons which is
completely wrong. This has been broken since the signless types change.
llvm-svn: 53444
2008-07-11 04:20:58 +00:00