1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 12:33:33 +02:00
Commit Graph

514 Commits

Author SHA1 Message Date
Chris Lattner
7c507ae857 fix PR5262.
llvm-svn: 84810
2009-10-22 00:17:26 +00:00
Chris Lattner
bf5a89d82b revert r84754, it isn't the right approach. Edwin, please propose
patches for fixes like this instead of committing them directly.

llvm-svn: 84799
2009-10-21 23:41:58 +00:00
Victor Hernandez
0996619220 Make changes to rev 84292 as requested by Chris Lattner.
Most changes are cleanup, but there is 1 correctness fix:
I fixed InstCombine so that the icmp is removed only if the malloc call is removed (which requires explicit removal because the Worklist won't DCE any calls since they can have side-effects).

llvm-svn: 84772
2009-10-21 19:11:40 +00:00
Torok Edwin
a8a12b7d98 Fix PR5262: when folding select into PHI, make sure all operands are available
in the PHI's Basic Block. This uses a conservative approach, because we don't
have dominator info in instcombine.

llvm-svn: 84754
2009-10-21 10:49:00 +00:00
Chris Lattner
e7c0e7f1a9 remove a now-pointless regtest
llvm-svn: 84409
2009-10-18 05:20:17 +00:00
Victor Hernandez
4d7283f82c Autoupgrade malloc insts to malloc calls.
Update testcases that rely on malloc insts being present.

Also prematurely remove MallocInst handling from IndMemRemoval and RaiseAllocations to help pass tests in this incremental step.

llvm-svn: 84292
2009-10-17 00:00:19 +00:00
Chris Lattner
a1f5264dd2 make instcombine's instruction sinking more aggressive in the
presence of PHI nodes.

llvm-svn: 84103
2009-10-14 15:21:58 +00:00
Edward O'Callaghan
da365e84bc Missing CHECK: lines makes test exit abnormally.
llvm-svn: 83835
2009-10-12 09:01:26 +00:00
Edward O'Callaghan
9393833f23 FileCheck not CheckFile, oops.
llvm-svn: 83834
2009-10-12 08:51:28 +00:00
Edward O'Callaghan
13bf3f7804 Convert InstCombine/call.ll to CheckFile.
llvm-svn: 83833
2009-10-12 08:46:47 +00:00
Edward O'Callaghan
4d633eaaae Convert the rest of the InstCombine tests from notcast to FileCheck.
llvm-svn: 83828
2009-10-12 07:18:14 +00:00
Nick Lewycky
3a206901cb Remove this part of the test, it never actually tested anything anyways. This
unbreaks make check after evocallaghan's changes.

llvm-svn: 83827
2009-10-12 06:32:42 +00:00
Edward O'Callaghan
0cc7f5e34a Fix syntax error missed in converting zext.ll test. Convert 2003-11-13-ConstExprCastCall.ll to FileCheck from notcast.
llvm-svn: 83826
2009-10-12 06:23:56 +00:00
Edward O'Callaghan
843b0c8830 Convert InstCombine tests from notcast to FileCheck.
llvm-svn: 83825
2009-10-12 06:14:06 +00:00
Chris Lattner
cb56deb798 reduce vec_shuffle2 and merge into vec_shuffle.
llvm-svn: 83807
2009-10-11 22:54:48 +00:00
Chris Lattner
33bff4602c filecheckize vec_shuffle.ll and merge shuffle.ll into it.
llvm-svn: 83806
2009-10-11 22:52:15 +00:00
Chris Lattner
b044bc079a filecheckize
llvm-svn: 83805
2009-10-11 22:45:17 +00:00
Chris Lattner
68ac2f7b2c rename test
llvm-svn: 83804
2009-10-11 22:44:16 +00:00
Chris Lattner
fa84cccd57 remove old testcase
llvm-svn: 83803
2009-10-11 22:42:06 +00:00
Chris Lattner
65bef57da8 merge test into shift.ll, this also eliminates awful grepping on -stats output
llvm-svn: 83802
2009-10-11 22:39:58 +00:00
Chris Lattner
bc0f470f07 convert to filecheck.
llvm-svn: 83801
2009-10-11 22:36:59 +00:00
Chris Lattner
b033a0ac47 teach instcombine to simplify xor's harder, catching the
new testcase.

llvm-svn: 83799
2009-10-11 22:22:13 +00:00
Chris Lattner
c8e0cdb676 convert xor2 to filecheck, merge in a random regtest
llvm-svn: 83796
2009-10-11 21:42:08 +00:00
Chris Lattner
100f3ac565 generalize a transformation even more: we don't care whether the
input the the mul is a zext from bool, just that it is all zeros
other than the low bit.  This fixes some phase ordering issues
that would cause us to miss some xforms in mul.ll when the worklist
is visited differently.

llvm-svn: 83794
2009-10-11 21:29:45 +00:00
Chris Lattner
40d1618562 simplify a transformation by making it more general.
llvm-svn: 83792
2009-10-11 21:22:21 +00:00
Chris Lattner
601cc4c588 implement rdar://7293527, a trivial instcombine that llvm-gcc
gets but clang doesn't, because it is implemented in GCC's
fold routine.

llvm-svn: 83761
2009-10-11 07:53:15 +00:00
Chris Lattner
513b66b237 instcombine shouldn't delete all null checks for mallocs.
This fixes PR5130.

llvm-svn: 83290
2009-10-05 02:47:47 +00:00
Chris Lattner
d77fb17b28 The select instruction is not neccesarily in the same block as the
phi nodes.  Make sure to phi translate from the right block. 

This fixes a llvm-building-llvm failure on GVN-PRE.cpp

llvm-svn: 82970
2009-09-28 06:49:44 +00:00
Chris Lattner
f7db1f1a3a Enhance the previous fix for PR4895 to allow more values than just
simple constants for the true/false value of the select.  We now
do phi translation etc.  This really fixes PR4895 :)

llvm-svn: 82917
2009-09-27 20:18:49 +00:00
Chris Lattner
0af7f0ceaf implement PR4895, by making FoldOpIntoPhi handle select conditions
that are phi nodes.  Also tighten up FoldOpIntoPhi to treat constantexpr
operands to phis just like other variables, avoiding moving constantexpr
computations around.

Patch by Daniel Dunbar.

llvm-svn: 82913
2009-09-27 19:57:57 +00:00
Nick Lewycky
6ea218a96b Filecheckify this one test.
llvm-svn: 82888
2009-09-27 06:25:05 +00:00
Dale Johannesen
53c365d807 Handle sqrt in CannotBeNegativeZero. absf and absl
appear to be misspellings, removed in favor of fabs*.

llvm-svn: 82796
2009-09-25 20:54:50 +00:00
Victor Hernandez
f772c0b8b2 Revert 82694 "Auto-upgrade malloc instructions to malloc calls." because it causes regressions in the nightly tests.
llvm-svn: 82784
2009-09-25 18:11:52 +00:00
Victor Hernandez
ff8027ced6 Auto-upgrade malloc instructions to malloc calls.
Reviewed by Devang Patel.

llvm-svn: 82694
2009-09-24 17:47:49 +00:00
Dan Gohman
2296899a6b Fix the comment in this test.
llvm-svn: 82051
2009-09-16 16:33:59 +00:00
Dan Gohman
77638f25b1 Don't sink gep operators through phi nodes if the result would require
more than one phi, since that leads to higher register pressure on
entry to the phi. This is especially problematic when the phi is in
a loop header, as it increases register pressure throughout the loop.

llvm-svn: 81993
2009-09-16 02:01:52 +00:00
Dan Gohman
205b641954 Change tests from "opt %s" to "opt < %s" so that opt doesn't see the
input filename so that opt doesn't print the input filename in the
output so that grep lines in the tests don't unintentionally match
strings in the input filename.

llvm-svn: 81537
2009-09-11 18:01:28 +00:00
Dan Gohman
aa66e3d968 Teach lib/VMCore/ConstantFold.cpp how to set the inbounds keyword and
how to fold notionally-out-of-bounds array getelementptr indices instead
of just doing these in lib/Analysis/ConstantFolding.cpp, because it can
be done in a fairly general way without TargetData, and because not all
constants are visited by lib/Analysis/ConstantFolding.cpp. This enables
more constant folding.

Also, set the "inbounds" flag when the getelementptr indices are
one-past-the-end.

llvm-svn: 81483
2009-09-11 00:04:14 +00:00
Dan Gohman
58a0550024 Factor out the code for checking that all indices in a getelementptr are
within the notional bounds of the static type of the getelementptr (which
is not the same as "inbounds") from GlobalOpt into a utility routine,
and use it in ConstantFold.cpp to check whether there are any mis-behaved
indices.

llvm-svn: 81478
2009-09-10 23:37:55 +00:00
Dan Gohman
0df0f8323c Use "opt < %s" instead of "opt %s" to keep the testname away from the grep.
llvm-svn: 81299
2009-09-09 00:22:49 +00:00
Dan Gohman
142428ce64 Eliminate more uses of llvm-as and llvm-dis.
llvm-svn: 81293
2009-09-09 00:09:15 +00:00
Dan Gohman
cd0fb89725 Use "opt < %s" instead of "opt %s" so that opt doesn't print the test
filename in the output, which interferes with the tests' grep lines.

llvm-svn: 81263
2009-09-08 22:57:49 +00:00
Dan Gohman
a3ab9b3b9e Convert a few more opt | llvm-dis to opt -S.
llvm-svn: 81261
2009-09-08 22:41:33 +00:00
Dan Gohman
c95df8b6d8 Use opt -S instead of piping bitcode output through llvm-dis.
llvm-svn: 81257
2009-09-08 22:34:10 +00:00
Chris Lattner
5caba6ecdc remove an extremely dubious instcombine transformation of
extractelement(load).

llvm-svn: 81239
2009-09-08 18:48:01 +00:00
Dan Gohman
8d84372836 Change these tests to feed the assembly files to opt directly, instead
of using llvm-as, now that opt supports this.

llvm-svn: 81226
2009-09-08 16:50:01 +00:00
Chris Lattner
12d0bc749f instcombine transforms vector loads that are only used by
extractelement operations into a bitcast of the pointer,
then a gep, then a scalar load.  Disable this when the vector
only has one element, because it leads to infinite loops in
instcombine (PR4908).

This transformation seems like a really bad idea to me, as it
will likely disable CSE of vector load/stores etc and can be
better done in the code generator when profitable.  This
goes all the way back to the first days of packed types,
r25299 specifically.

I'll let those people who care about the performance of vector
code decide what to do with this.

llvm-svn: 81185
2009-09-08 03:44:51 +00:00
Chris Lattner
37dbbde91b fix ComputeMaskedBits handling of zext/sext/trunc to work with vectors.
This fixes PR4905

llvm-svn: 81174
2009-09-08 00:13:52 +00:00
Daniel Dunbar
b220fd9c58 Don't depend on Tcl behavior of redirecting stderr for all commands in a
pipeline.

llvm-svn: 81153
2009-09-07 19:26:02 +00:00
Daniel Dunbar
a953c39b9e Eliminate uses of %prcontext.
- I'd appreciate it if someone else eyeballs my changes to make sure I captured
   the intent of the test.

llvm-svn: 81083
2009-09-05 11:35:16 +00:00
Chris Lattner
8bb351e2c2 fix PR4837, some bugs folding vector compares. These
return a vector of i1, not i1 itself.

llvm-svn: 80761
2009-09-02 05:12:37 +00:00
Chris Lattner
73d1e17cec fix a bug I introduced with my 'instcombine builder' refactoring
changes: SimplifyDemandedBits can't use the builder yet because it
has the wrong insertion point.  This fixes a crash building
MultiSource/Benchmarks/PAQ8p

llvm-svn: 80537
2009-08-31 04:36:22 +00:00
Chris Lattner
1c81f120e2 suck a bunch more gep tests into getelementptr.ll and filecheckize them all.
llvm-svn: 80517
2009-08-30 21:31:34 +00:00
Chris Lattner
1c8bd32732 consolodate various GEP tests into getelementptr.ll using filecheck.
llvm-svn: 80514
2009-08-30 21:02:36 +00:00
Chris Lattner
ac17c19a06 another huge testcase, this time from 'gs' in llvm-test.
llvm-svn: 80513
2009-08-30 21:02:02 +00:00
Chris Lattner
6c6cd82568 remove another poorly-reduced testcase which came from ldecod in llvm-test.
llvm-svn: 80512
2009-08-30 21:01:14 +00:00
Chris Lattner
94ea2fb674 this testcase is 500 lines long and is distilled from bzip2, just
remove it.

llvm-svn: 80511
2009-08-30 21:00:11 +00:00
Chris Lattner
22c8be162d convert to filecheck
llvm-svn: 80510
2009-08-30 20:48:15 +00:00
Chris Lattner
d21a94f8d6 Fix PR4748: don't fold gep(bitcast(x)) into bitcast(gep) when x
is itself a bitcast.  Since we have gep(bitcast(bitcast(y))) in this
case, just wait for the two bitcasts to get zapped.  This prevents
instcombine from confusing some aliasing stuff, and allows it to
directly eliminate the load in the testcase.

llvm-svn: 80508
2009-08-30 20:38:21 +00:00
Dan Gohman
bf08e82d8e Remove obsolete -f flags.
llvm-svn: 79992
2009-08-25 15:38:29 +00:00
Dan Gohman
d240c19451 Change getelementptr folding to use APInt instead of uint64_t for
offset computations. This fixes a truncation bug on targets that
don't have 64-bit pointers.

llvm-svn: 79639
2009-08-21 16:52:54 +00:00
Dan Gohman
cc511acf87 Fix a bug in the over-index constant folding. When over-indexing an
array member of a struct, it's possible to land in an arbitrary position
inside that struct, such that attempting to find further getelementptr
indices will fail. In such cases, folding cannot be done.

llvm-svn: 79485
2009-08-19 22:46:59 +00:00
Dan Gohman
bc59c24278 Canonicalize indices in a constantexpr GEP. If Indices exceed the
static extents of the static array type, it causes GlobalOpt and
other passes to be more conservative. This canonicalization also
allows the constant folder to add "inbounds" to GEPs.

llvm-svn: 79440
2009-08-19 18:18:36 +00:00
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
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
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
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
Eli Friedman
63028801b8 Fix trivial todo in instcombine.
llvm-svn: 75586
2009-07-14 02:01:53 +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
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
dc884a7830 Generalize the zext(trunc(t) & C) instcombine to work even with
C is not a low-bits mask, and add a similar instcombine for
zext((trunc(t) & C) ^ C).

llvm-svn: 73705
2009-06-18 16:30:21 +00:00
Dan Gohman
1530824138 Instcombine zext(trunc(x) & mask) to x&mask, even if the trunc has
multiple users.

llvm-svn: 73656
2009-06-17 23:17:05 +00:00
Eli Friedman
36d7ca738e Correct an accidental duplication of the test (patch doesn't handle
creating new files very well).

llvm-svn: 73599
2009-06-17 03:05:00 +00:00
Eli Friedman
b3947071ff PR3439: Correct a silly mistake in the SimplifyDemandedUseBits code for
SRem.

llvm-svn: 73598
2009-06-17 02:57:36 +00:00
Dan Gohman
54bbef1525 Generalize a few more instcombines to be vector/scalar-independent.
llvm-svn: 73541
2009-06-16 19:55:29 +00:00
Chris Lattner
f54c97c579 Testcase for r73506
llvm-svn: 73508
2009-06-16 17:23:25 +00:00
Dan Gohman
2e737ac21f Support vector casts in more places, fixing a variety of assertion
failures.

To support this, add some utility functions to Type to help support
vector/scalar-independent code. Change ConstantInt::get and
ConstantFP::get to support vector types, and add an overload to
ConstantInt::get that uses a static IntegerType type, for
convenience.

Introduce a new getConstant method for ScalarEvolution, to simplify
common use cases.

llvm-svn: 73431
2009-06-15 22:12:54 +00:00
Chris Lattner
52510b0788 fix testcase to properly check for the patch in r73195.
llvm-svn: 73380
2009-06-15 05:46:02 +00:00
Dan Gohman
f9b0419cd8 Don't do (x - (y - z)) --> (x + (z - y)) on floating-point types, because
it may round differently. This fixes PR4374.

llvm-svn: 73243
2009-06-12 19:23:25 +00:00
Chris Lattner
e0360f8ae8 Fix 4366: store to null in non-default addr space should not be
turned into unreachable.

llvm-svn: 73195
2009-06-11 17:54:56 +00:00
Eli Friedman
770f633389 PR4340: Run SimplifyDemandedVectorElts on insertelement instructions;
sometimes it can find simplifications that won't be found otherwise.

llvm-svn: 73006
2009-06-06 20:08:03 +00:00