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

8392 Commits

Author SHA1 Message Date
Eli Friedman
22c39edd2e Fix a couple hash functions so that they do not depend on undefined shifts. Based on patch by Ahmed Charles.
llvm-svn: 141820
2011-10-12 22:00:26 +00:00
Nick Lewycky
e7b3961fab Add missing space.
llvm-svn: 141750
2011-10-12 00:14:31 +00:00
Cameron Zwarich
fac176ac51 Fix PR11106 by correcting a typo that has been in the code for over a year. This
would have never worked, since the element type of a vector type is never a
vector type. Also fix the conditional to be more direct in checking whether
EltTy is a vector type.

llvm-svn: 141713
2011-10-11 21:26:40 +00:00
Cameron Zwarich
a34d748f83 Remove a lot of the fancy scalar replacement code for dealing with llvm-gcc's
lowering of NEON code. It provides little-to-no benefit now and only introduces
additional complexity.

llvm-svn: 141646
2011-10-11 06:10:30 +00:00
Andrew Trick
23866a5e65 Add experimental -enable-lsr-phielim option.
I'm not sure we will need it in the long run, but the option is
currently useful for checking if the output of LSR is "clean".

llvm-svn: 141634
2011-10-11 02:30:45 +00:00
Andrew Trick
d36852e6b1 Move replaceCongruentIVs into SCEVExapander and bias toward "expanded"
IVs.

Indvars previously chose randomly between congruent IVs. Now it will
bias the decision toward IVs that SCEVExpander likes to create. This
was not done to fix any problem, it's just a welcome side effect of
factoring code.

llvm-svn: 141633
2011-10-11 02:28:51 +00:00
Lang Hames
be4997db2f Add a natural stack alignment field to TargetData, and prevent InstCombine from
promoting allocas to preferred alignments that exceed the natural
alignment. This avoids some potentially expensive dynamic stack realignments.

The natural stack alignment is set in target data strings via the "S<size>"
option. Size is in bits and must be a multiple of 8. The natural stack alignment
defaults to "unspecified" (represented by a zero value), and the "unspecified"
value does not prevent any alignment promotions. Target maintainers that care
about avoiding promotions should explicitly add the "S<size>" option to their
target data strings.

llvm-svn: 141599
2011-10-10 23:42:08 +00:00
Andrew Trick
75743b069e LSR should only reuse phis that match its formula.
Fixes rdar://problem/5064068

llvm-svn: 141442
2011-10-07 23:46:21 +00:00
Duncan Sands
559ef2f491 Teach GVN to also propagate switch cases. For example, in this code
switch (n) {
    case 27:
      do_something(x);
    ...
  }
the call do_something(x) will be replaced with do_something(27).  In
gcc-as-one-big-file this results in the removal of about 500 lines of
bitcode (about 0.02%), so has about 1/10 of the effect of propagating
branch conditions.

llvm-svn: 141360
2011-10-07 08:29:06 +00:00
Eli Friedman
4d63ca106a Remove the old atomic instrinsics. autoupgrade functionality is included with this patch.
llvm-svn: 141333
2011-10-06 23:20:49 +00:00
Eli Friedman
dd48bb30de PR11061: Make simplifylibcalls fold strcmp("", x) correctly.
While I'm here, fix the related issue with strncmp, add some actual tests for strcmp and strncmp, and start using StringRef::compare for constant folding instead of using strcmp/strncmp so that the optimized IR isn't dependent on the host's implementation of strcmp.

llvm-svn: 141227
2011-10-05 22:27:16 +00:00
Jim Grosbach
a0e2c52a5c Re-commit 141203, but much more conservative.
Just pull the instruction name, but don't change the order of anything
else. That keeps --debug happy and non-crashing, but doesn't change
how the worklist gets built.

llvm-svn: 141210
2011-10-05 20:53:43 +00:00
Jim Grosbach
254b9ed208 Revert 141203. InstCombine is looping on unit tests.
llvm-svn: 141209
2011-10-05 20:44:29 +00:00
Jim Grosbach
a03dd9189f Update InstCombine worklist after instruction transform is complete.
When updating the worklist for InstCombine, the Add/AddUsersToWorklist
functions may access the instruction(s) being added, for debug output for
example. If the instructions aren't yet added to the basic block, this
can result in a crash. Finish the instruction transformation before
adjusting the worklist instead.

rdar://10238555

llvm-svn: 141203
2011-10-05 20:05:00 +00:00
Duncan Sands
f7df28c1f5 GVN does simple propagation of conditions: when it sees a conditional
branch "br i1 %x, label %if_true, label %if_false" then it replaces
"%x" with "true" in places only reachable via the %if_true arm, and
with "false" in places only reachable via the %if_false arm.  Except
that actually it doesn't: if value numbering shows that %y is equal
to %x then, yes, %y will be turned into true/false in this way, but
any occurrences of %x itself are not transformed.  Fix this.  What's
more, it's often the case that %x is an equality comparison such as
"%x = icmp eq %A, 0", in which case every occurrence of %A that is
only reachable via the %if_true arm can be replaced with 0.  Implement
this and a few other variations on this theme.  This reduces the number
of lines of LLVM IR in "GCC as one big file" by 0.2%.  It has a bigger
impact on Ada code, typically reducing the number of lines of bitcode
by around 0.4% by removing repeated compiler generated checks.  Passes
the LLVM nightly testsuite and the Ada ACATS testsuite.

llvm-svn: 141177
2011-10-05 14:28:49 +00:00
Duncan Sands
348e8c285a Generalize GVN's conditional propagation logic slightly:
it's OK for the false/true destination to have multiple
predecessors as long as the extra ones are dominated by
the branch destination.

llvm-svn: 141176
2011-10-05 14:17:01 +00:00
Andrew Trick
c60e2addd9 LSR should avoid redundant edge splitting.
This handles the case in which LSR rewrites an IV user that is a phi and
splits critical edges originating from a switch.
Fixes <rdar://problem/6453893> LSR is not splitting edges "nicely"

llvm-svn: 141059
2011-10-04 03:50:44 +00:00
Andrew Trick
94d203b172 whitespace
llvm-svn: 141058
2011-10-04 03:34:49 +00:00
Nick Lewycky
7cd1bfb89d Add a new icmp+select optz'n. Also shows off the load(cst) folding added in
r140966.

llvm-svn: 140969
2011-10-02 10:37:37 +00:00
Nick Lewycky
3282ef025d Enhance a couple places where we were doing constant folding of instructions,
but not load instructions. Noticed by inspection.

llvm-svn: 140966
2011-10-02 09:12:55 +00:00
Andrew Trick
0489c5410d Inlining and unrolling heuristics should be aware of free truncs.
We want heuristics to be based on accurate data, but more importantly
we don't want llvm to behave randomly. A benign trunc inserted by an
upstream pass should not cause a wild swings in optimization
level. See PR11034. It's a general problem with threshold-based
heuristics, but we can make it less bad.

llvm-svn: 140919
2011-10-01 01:39:05 +00:00
Andrew Trick
a1161d94f5 whitespace
llvm-svn: 140916
2011-10-01 01:27:56 +00:00
Jim Grosbach
96af96b83d Don't modify constant in-place.
llvm-svn: 140875
2011-09-30 19:58:46 +00:00
Jim Grosbach
d35eaaeb6e float comparison to double 'zero' constant can just be a float 'zero.'
InstCombine was incorrectly considering the conversion of the constant
zero to be unsafe.

We want to transform:
define float @bar(float %x) nounwind readnone optsize ssp {
  %conv = fpext float %x to double
  %cmp = fcmp olt double %conv, 0.000000e+00
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
}

Into:
define float @bar(float %x) nounwind readnone optsize ssp {
  %cmp = fcmp olt float %x, 0.000000e+00   ; <---- This
  %conv1 = zext i1 %cmp to i32
  %conv2 = sitofp i32 %conv1 to float
  ret float %conv2
}


rdar://10215914

llvm-svn: 140869
2011-09-30 18:45:50 +00:00
Jim Grosbach
651c847dc5 Tidy up. Trailing whitespace.
llvm-svn: 140865
2011-09-30 18:09:53 +00:00
Duncan Sands
b4c8b2d9fa Inlining often produces landingpad instructions with repeated
catch or repeated filter clauses.  Teach instcombine a bunch
of tricks for simplifying landingpad clauses.  Currently the
code only recognizes the GNU C++ and Ada personality functions,
but that doesn't stop it doing a bunch of "generic" transforms
which are hopefully fine for any real-world personality function.
If these "generic" transforms turn out not to be generic, they
can always be conditioned on the personality function.  Probably
someone should add the ObjC++ personality function.  I didn't as
I don't know anything about it.

llvm-svn: 140852
2011-09-30 13:12:16 +00:00
Nick Lewycky
fc476a3d3f Fold two identical set lookups into one. No functionality change.
llvm-svn: 140821
2011-09-29 23:40:12 +00:00
Dan Gohman
7dca165e93 When eliminating unnecessary retain+autorelease on return values,
handle the case where the retain is in a different basic block.
rdar://10210274.

llvm-svn: 140815
2011-09-29 22:27:34 +00:00
Dan Gohman
2df048a94b Don't eliminate objc_retainBlock calls on stack objects if the
objc_retainBlock call is potentially responsible for copying
the block to the heap to extend its lifetime. rdar://10209613.

llvm-svn: 140814
2011-09-29 22:25:23 +00:00
Eli Friedman
ac33381aa1 Clean up uses of switch instructions so they are not dependent on the operand ordering. Patch by Stepan Dyatkovskiy.
llvm-svn: 140803
2011-09-29 20:21:17 +00:00
Andrew Trick
fa2c108a22 typo + pasto
llvm-svn: 140769
2011-09-29 01:53:08 +00:00
Andrew Trick
e1d5ae73ac LSR: rewrite inner loops only.
Rewriting the entire loop nest now requires -enable-lsr-nested.
See PR11035 for some performance data.
A few unit tests specifically test nested LSR, and are now under a flag.

llvm-svn: 140762
2011-09-29 01:33:38 +00:00
Andrew Trick
97b40d3aff indvars should hoist [sz]ext because licm is not rerun.
llvm-svn: 140670
2011-09-28 01:35:36 +00:00
Benjamin Kramer
355b353595 Stop emitting instructions with the name "tmp" they eat up memory and have to be uniqued, without any benefit.
If someone prefers %tmp42 to %42, run instnamer.

llvm-svn: 140634
2011-09-27 20:39:19 +00:00
Bill Wendling
589336d854 Split the landing pad basic block with the correct function. Also merge the
split landingpad instructions into a PHI node.
PR11016

llvm-svn: 140592
2011-09-27 00:59:31 +00:00
Andrew Trick
eb2bea7d4a Disable LSR retry by default.
Disabling aggressive LSR saves compilation time, and with the new
indvars behavior usually improves performance.

llvm-svn: 140590
2011-09-27 00:44:14 +00:00
Andrew Trick
9a82406730 LSR, one of the new Cost::isLoser() checks did not get merged in the previous checkin.
llvm-svn: 140583
2011-09-26 23:35:25 +00:00
Andrew Trick
4dfc60fab6 LSR cost metric minor fix and verification.
The minor bug heuristic was noticed by inspection. I added the
isLoser/isValid helpers because they will become more
important with subsequent checkins.

llvm-svn: 140580
2011-09-26 23:11:04 +00:00
Andrew Trick
3540419340 LSR minor bug fix in RateRegister.
No test case. Noticed by inspection and I doubt it ever affects the
outcome of the overall heuristic, let alone final codegen.

llvm-svn: 140431
2011-09-23 23:05:19 +00:00
Eli Friedman
6e15091fc6 PR10987: add a missed safety check to isSafePHIToSpeculate in scalarrepl.
llvm-svn: 140327
2011-09-22 18:56:30 +00:00
Eli Friedman
2599a202e2 Make sure IPSCCP never marks a tracked call as overdefined in SCCPSolver::ResolvedUndefsIn. If we do, we can end up in a situation where a function is resolved to return a constant, but the caller is marked overdefined, which confuses the code later.
<rdar://problem/9956541> (again).

llvm-svn: 140210
2011-09-20 23:28:51 +00:00
Bill Wendling
32444d6a28 Relax this condition.
Some passes require breaking critical edges before they're called. Don't
segfault because of that.

llvm-svn: 140196
2011-09-20 22:28:17 +00:00
Bill Wendling
5860a42997 Place the check for an exit landing pad where it will be run on both code paths through the if-then-else.
llvm-svn: 140195
2011-09-20 22:27:16 +00:00
Bill Wendling
9e1900bcf7 Omit extracting a loop if one of the exits is a landing pad.
The landing pad must accompany the invoke when it's extracted. However, if it
does, then the loop isn't properly extracted. I.e., the resulting extraction has
a loop in it. The extracted function is then extracted, etc. resulting in an
infinite loop.

llvm-svn: 140193
2011-09-20 22:23:09 +00:00
Bill Wendling
cf8d277150 Check the terminator, not the basic block.
llvm-svn: 140176
2011-09-20 20:20:50 +00:00
Bill Wendling
1ac89f2739 When extracting a basic block that ends in an 'invoke' instruction, we need to
extract its associated landing pad block as well. However, that landing pad
block may have more than one predecessor. So split the landing pad block so that
individual landing pads have only one predecessor.

This type of transformation may produce a false positive with bugpoint.

llvm-svn: 140173
2011-09-20 19:10:24 +00:00
Bill Wendling
66d2eeb730 Use ArrayRef instead of an explicit 'const std::vector &'.
llvm-svn: 140172
2011-09-20 19:05:04 +00:00
Devang Patel
76e4b3cba8 If simple ownership works then friendship is not required.
llvm-svn: 140169
2011-09-20 18:48:56 +00:00
Bill Wendling
8a13959e3a Use ArrayRef instead of 'const std::vector' to pass around the list of basic blocks to extract.
llvm-svn: 140168
2011-09-20 18:42:07 +00:00
Devang Patel
5332ddba93 Update GCOVLines to provide interfaces to write line table and calculate complete length.
llvm-svn: 140167
2011-09-20 18:35:00 +00:00