Mon P Wang
d56e4482fc
When InstCombine simplifies a load -> extract element to gep -> load, place
...
the new load by the old load instead of by the extract element because
a store could have occurred between the load and extract element.
llvm-svn: 78891
2009-08-13 05:12:13 +00:00
Dan Gohman
9f80d2be6b
Make LLVM Assembly dramatically easier to read by aligning the comments,
...
using formatted_raw_ostream's PadToColumn.
Before:
bb1: ; preds = %bb
%2 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%3 = getelementptr double* %p, i64 %2 ; <double*> [#uses=1]
%4 = load double* %3, align 8 ; <double> [#uses=1]
%5 = fmul double %4, 1.100000e+00 ; <double> [#uses=1]
%6 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%7 = getelementptr double* %p, i64 %6 ; <double*> [#uses=1]
After:
bb1: ; preds = %bb
%2 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%3 = getelementptr double* %p, i64 %2 ; <double*> [#uses=1]
%4 = load double* %3, align 8 ; <double> [#uses=1]
%5 = fmul double %4, 1.100000e+00 ; <double> [#uses=1]
%6 = sext i32 %i.01 to i64 ; <i64> [#uses=1]
%7 = getelementptr double* %p, i64 %6 ; <double*> [#uses=1]
Several tests required whitespace adjustments.
llvm-svn: 78816
2009-08-12 17:23:50 +00:00
Dan Gohman
00ee3a9a1a
Transform -X/C to X/-C, implementing a README.txt entry.
...
llvm-svn: 78812
2009-08-12 16:37:02 +00:00
Dan Gohman
d5b6e35080
Optimize (x/C)*C to x if the division is exact.
...
llvm-svn: 78811
2009-08-12 16:33:09 +00:00
Dan Gohman
8d69df5773
Optimize exact sdiv by a constant power of 2 to ashr.
...
llvm-svn: 78714
2009-08-11 20:47:47 +00:00
Dan Gohman
08e747855c
Don't assume that external global variables are aligned at their preferred
...
alignment. Only the minimum alignment guaranteed by the ABI may be assumed.
llvm-svn: 78668
2009-08-11 15:50:03 +00:00
Dan Gohman
aba682a290
Add -disable-output. Thanks Bill!
...
llvm-svn: 78009
2009-08-03 22:24:22 +00:00
Dan Gohman
39f93f6443
Add a new Constant::getIntegerValue helper function, and convert a
...
few places in InstCombine to use it, to fix problems handling pointer
types. This fixes the recent llvm-gcc bootstrap error.
llvm-svn: 78005
2009-08-03 22:07:33 +00:00
Eli Friedman
7bb0485237
PR4662: Fix a crash introduced by the recent LLVMContext changes.
...
llvm-svn: 77716
2009-07-31 19:36:47 +00:00
Daniel Dunbar
89cb72a6bc
Fix PR4645 which was fallout from the fix for PR4641.
...
- Call RAUW to delete all instructions (this is a patch from Nick Lewycky).
llvm-svn: 77512
2009-07-29 22:00:43 +00:00
Nick Lewycky
1961298b63
Just discard the output, no need to turn it back into text.
...
llvm-svn: 77439
2009-07-29 06:14:52 +00:00
Chris Lattner
e5f1099d05
don't dump .bc file to stdout, and simplify this to a trivial testcase.
...
llvm-svn: 77436
2009-07-29 05:32:07 +00:00
Nick Lewycky
e0524c1795
Bulk erasing instructions without RAUWing them is unsafe. Instead, break them
...
into a new BB that has no predecessors.
llvm-svn: 77433
2009-07-29 05:17:50 +00:00
Dan Gohman
0d0dd7b732
Teach instcombine to respect and preserve inbounds. Add inbounds
...
to a few tests where it is required for the expected transformation.
llvm-svn: 77290
2009-07-28 01:40:03 +00:00
Chris Lattner
0426853d67
merge vector-casts-0.ll into vector-casts.ll
...
llvm-svn: 76864
2009-07-23 05:33:39 +00:00
Chris Lattner
c687344f0c
Make some existing optimizations that would only trigger on scalars
...
also apply to vectors. This allows us to compile this:
#include <emmintrin.h>
__m128i a(__m128 a, __m128 b) { return a==a & b==b; }
__m128i b(__m128 a, __m128 b) { return a!=a | b!=b; }
to:
_a:
cmpordps %xmm1, %xmm0
ret
_b:
cmpunordps %xmm1, %xmm0
ret
with clang instead of to a ton of horrible code.
llvm-svn: 76863
2009-07-23 05:32:17 +00:00
Chris Lattner
f4474da353
convert a test to filecheck format. This fixes an endemic problem
...
with negative tests: this test wasn't checking what it thought it was
because it was grepping .bc, not .ll.
llvm-svn: 76861
2009-07-23 05:27:48 +00:00
Chris Lattner
7061a4300d
rename test
...
llvm-svn: 76860
2009-07-23 05:25:12 +00:00
Dan Gohman
f2c6e6a1bd
Add a testcase for PR2831.
...
llvm-svn: 76527
2009-07-21 01:02:18 +00:00
Dan Gohman
74a435e9f1
The upper argument of ConstantRange is exclusive, not inclusive.
...
llvm-svn: 76492
2009-07-20 22:34:18 +00:00
Dan Gohman
00b05492f1
Revert the addition of hasNoPointerOverflow to GEPOperator.
...
Getelementptrs that are defined to wrap are virtually useless to
optimization, and getelementptrs that are undefined on any kind
of overflow are too restrictive -- it's difficult to ensure that
all intermediate addresses are within bounds. I'm going to take
a different approach.
Remove a few optimizations that depended on this flag.
llvm-svn: 76437
2009-07-20 17:43:30 +00:00
Eli Friedman
e507c1afaa
Canonicalize bitcasts between types like <1 x i64> and i64 to
...
insertelement/extractelement.
I'm not entirely sure this is precisely what we want to do: should we
prefer bitcast(insertelement) or insertelement(bitcast)? Similarly. should we
prefer extractelement(bitcast) or bitcast(extractelement)?
llvm-svn: 76345
2009-07-18 23:06:53 +00:00
Eli Friedman
debc43cb11
Back out 76300; apparently the preference is to canonicalize the other
...
way (bitcast -> insert/extractelement).
llvm-svn: 76325
2009-07-18 19:04:16 +00:00
Eli Friedman
65a5fe312a
Add combine: X sdiv (1 << Y) -> X udiv (1 << Y) when X doesn't have the
...
sign bit set.
llvm-svn: 76304
2009-07-18 09:53:21 +00:00
Eli Friedman
f1878fcda1
Canonicalize insert/extractelement from single-element vectors into
...
bitcasts.
It would also be possible to canonicalize the other way; does anyone
have a preference?
llvm-svn: 76300
2009-07-18 09:07:47 +00:00
Eli Friedman
7b1597133d
Fix simplifylibcalls memset recognition to work on 64-bit platforms
...
where int is 32 bits.
llvm-svn: 76293
2009-07-18 08:34:51 +00:00
Dan Gohman
50e65d8c93
Fill in some holes in ScalarEvolution's loop iteration condition
...
analysis. This allows indvars to emit a simpler loop trip count
expression.
llvm-svn: 76085
2009-07-16 17:34:36 +00:00
Eli Friedman
6aa39dcd93
Switch invars away from using isTrapping when it really shouldn't be
...
using it.
llvm-svn: 75852
2009-07-15 22:48:29 +00:00
Eli Friedman
048d13f9bb
Don't restrict the set of instructions where we try to constant-fold the
...
operands; it's possible to end up with a constant-foldable operand to
most instructions, even those which can't trap.
llvm-svn: 75845
2009-07-15 22:13:34 +00:00
Dan Gohman
5329511fae
Fix the expansion of umax and smax in the case where one or more of
...
the operands have pointer type, so that the resulting type matches
the original SCEV type, and so that unnecessary ptrtoints are
avoided in common cases.
llvm-svn: 75680
2009-07-14 20:57:04 +00:00
Dan Gohman
9525cf679f
Add a testcase for a bug fixed by r75634.
...
llvm-svn: 75644
2009-07-14 18:15:00 +00:00
Dale Johannesen
35fc3243a8
Revert 75571; I'm convinced this isn't the right thing to do.
...
llvm-svn: 75642
2009-07-14 17:48:25 +00:00
Eli Friedman
63028801b8
Fix trivial todo in instcombine.
...
llvm-svn: 75586
2009-07-14 02:01:53 +00:00
Dan Gohman
493855541b
Update LoopSimplify and LoopUnswitch to use the new makeLoopInvariant
...
function.
llvm-svn: 75584
2009-07-14 01:37:59 +00:00
Dan Gohman
b9f3a3c96b
Fix indvars to not assume that a loop with a single unique exit
...
block has a single unique exiting block.
llvm-svn: 75579
2009-07-14 01:09:02 +00:00
Dale Johannesen
de1ed58935
Don't delete asm's just because their inputs are undefined;
...
xor R, R is a common and valid idiom for zeroing a register, for example.
llvm-svn: 75571
2009-07-14 00:45:38 +00:00
Eli Friedman
a6c7a3d44e
PR4548: optimize zext+udiv+trunc to udiv.
...
llvm-svn: 75539
2009-07-13 22:46:01 +00:00
Eli Friedman
47839d3dec
Fix bug in run-line.
...
llvm-svn: 75534
2009-07-13 22:31:30 +00:00
Eli Friedman
6b51ac6728
Canonicalize boolean +/- a constant to a select.
...
(I think it's reasonably clear that we want to have a canonical form for
constructs like this; if anyone thinks that a select is not the best
canonical form, please tell me.)
llvm-svn: 75531
2009-07-13 22:27:52 +00:00
Dan Gohman
a9953c0a28
Reapply 75252, with a fix to avoid the infinite recursion case. The
...
check for avoiding re-analyzing a widening cast needed to happen
earlier, as getSCEV itself may result in a isLoopGuardedByCond query.
llvm-svn: 75511
2009-07-13 21:35:55 +00:00
Chris Lattner
b4bd955891
Move the re-sort of invalidated NonLocalPointerDeps cache earlier
...
so that all code paths get it. PR4256 was about a case where the
phi translation loop would find all preds in the Visited cache, so
it could get by without re-sorting the NonLocalPointerDeps cache.
Fix this by resorting it earlier, there is no reason not to do this.
This patch inspired by Jakub Staszak's patch.
llvm-svn: 75476
2009-07-13 17:14:23 +00:00
Nick Lewycky
d3d5cfa475
Revert r75252 which was causing some crashes at compile time.
...
llvm-svn: 75384
2009-07-11 20:38:25 +00:00
Dan Gohman
404a92e330
Generalize ScalarEvolution's cast-folding code to support more kinds
...
of loops. Add several new functions to for working with ScalarEvolution's
add-hoc value-range analysis functionality.
llvm-svn: 75252
2009-07-10 16:42:52 +00:00
Nick Lewycky
c707d9c60d
There's no need to consider PHI nodes in the same block as the instruction
...
we're inserting sigma/phi functions for. Patch by Andre Tavares.
llvm-svn: 75138
2009-07-09 15:59:27 +00:00
Nick Lewycky
d46a7b2d22
Remove the vicmp and vfcmp instructions. Because we never had a release with
...
these instructions, no autoupgrade or backwards compatibility support is
provided.
llvm-svn: 74991
2009-07-08 03:04:38 +00:00
Chris Lattner
54c0359890
do not try to analyze bitcasts from i64 to <2 x i32> in ComputedMaskedBits. While
...
we could do this, doing so requires adjusting the demanded mask and the code isn't
doing that yet. This fixes PR4495
llvm-svn: 74699
2009-07-02 16:04:08 +00:00
Dan Gohman
e3b1f9e14b
Fix an instcombine abort on a scalar-to-vector bitcast. This fixes PR4487.
...
llvm-svn: 74646
2009-07-01 21:38:46 +00:00
Dan Gohman
d496b35af0
Don't cache PHI exit values from exhaustive evaluations, because
...
an individual exhaustive evaluation reflects only the exit value
implied by an individual exit, which may differ from the actual
exit value of the loop if there are other exits. This fixes PR4477.
llvm-svn: 74447
2009-06-29 20:34:13 +00:00
Dan Gohman
28702fab4e
Don't try to split a loop when the controlling icmp instruction
...
doesn't have an IV-based operand. This fixes PR4471.
llvm-svn: 74399
2009-06-27 22:58:27 +00:00
Dan Gohman
8d2a45fadb
Teach LoopSimplify how to merge multiple loop exits into a single exit,
...
when one of them can be converted to a trivial icmp and conditional
branch.
This addresses what is essentially a phase ordering problem.
SimplifyCFG knows how to do this transformation, but it doesn't do so
if the primary block has any instructions in it other than an icmp and
a branch. In the given testcase, the block contains other instructions,
however they are loop-invariant and can be hoisted. SimplifyCFG doesn't
have LoopInfo though, so it can't hoist them. And, it's important that
the blocks be merged before LoopRotation, as it doesn't support
multiple-exit loops.
llvm-svn: 74396
2009-06-27 21:30:38 +00:00