84 Commits

Author SHA1 Message Date
Daniel Berlin
7824530ee0 NewGVN: Fix PR33204 - We need to add memory users when we bypass memorydefs for loads, not just when we do it for stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311829 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-26 07:37:11 +00:00
Daniel Berlin
9dc6eddb1d NewGVN: We weren't properly simplifying selects with equal arguments due to a thinko.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311626 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24 02:43:17 +00:00
Sam Elliott
74a34d9193 Keep Optimization Remark Yaml in NewPM
Summary:
The New Pass Manager infrastructure was forgetting to keep around the optimization remark yaml file that the compiler might have been producing. This meant setting the option to '-' for stdout worked, but setting it to a filename didn't give file output (presumably it was deleted because compilation didn't explicitly keep it). This change just ensures that the file is kept if compilation succeeds.

So far I have updated one of the optimization remark output tests to add a version with the new pass manager. It is my intention for this patch to also include changes to all tests that use `-opt-remark-output=` but I wanted to get the code patch ready for review while I was making all those changes.

Fixes https://bugs.llvm.org/show_bug.cgi?id=33951

Reviewers: anemet, chandlerc

Reviewed By: anemet, chandlerc

Subscribers: javed.absar, chandlerc, fhahn, llvm-commits

Differential Revision: https://reviews.llvm.org/D36906

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311271 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-20 01:30:45 +00:00
Chad Rosier
0db3a4f041 [NewGVN] Add CL option to control the generation of phi-of-ops (disable by default).
Differential Revision: https://reviews.llvm.org/D36478539

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310594 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-10 14:12:57 +00:00
Davide Italiano
0d362a25a4 [NewGVN] Fix the case where we have a phi-of-ops which goes away.
Patch by Daniel Berlin, fixes PR33196 (and probably something else).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309988 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-03 21:17:49 +00:00
Davide Italiano
82f73ee5b3 [NewGVN] Now that load coercion is enable, we pass this test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309872 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-02 19:47:37 +00:00
Davide Italiano
17015f9a54 [NewGVN] Check for congruency of memory accesses.
This is fine as nothing in the code relies on leader and memory
leader being the same for a given congruency class. Ack'ed by
Dan.

Fixes PR33720.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-11 19:49:12 +00:00
Daniel Berlin
47c282c3df NewGVN: Fix PR 33461, caused by slightly overzealous verification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305657 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-19 00:24:00 +00:00
Daniel Berlin
2d73c379ee NewGVN: Fix PR/33187. This is a bug caused by two things:
1. When there is no perfect iteration order, we can't let phi nodes
put themselves in terms of things that come later in the iteration
order, or we will endlessly cycle (the normal RPO algorithm clears the
hashtable to avoid this issue).
2. We are sometimes erasing the wrong expression (causing pessimism)
because our equality says loads and stores are the same.
We introduce an exact equality function and use it when erasing to
make sure we erase only identical expressions, not equivalent ones.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304807 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 17:15:28 +00:00
Joey Gouly
4d04e9b25e [InstSimplify] Constant fold the new GEP in SimplifyGEPInst.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304784 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 10:17:14 +00:00
Daniel Berlin
a76241a0a5 NewGVN: Fix PR 33185 by checking whether we need to recursively
generate a phi of ops, which we don't currently support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304272 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-31 01:47:32 +00:00
Daniel Berlin
e99d769512 Fix test that wasn't update_test_check'd
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304271 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-31 01:47:29 +00:00
Daniel Berlin
4133415c70 NewGVN: Fix PR 33119, PR 33129, due to regressed undef handling
Fix PR33120 and others by eliminating self-cycles a different way.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303875 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 15:44:20 +00:00
Davide Italiano
6ff9a78ce5 [NewGVN] Update additionalUsers when we simplify to a value.
Otherwise we don't revisit an instruction that could be simplified,
and when we verify, we discover there's something that changed, i.e.
what we had wasn't a maximal fixpoint.

Fixes PR32836.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303715 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-24 02:30:24 +00:00
Daniel Berlin
cc24c88dcf NewGVN: Fix PR 33116, the memoryphi version of bug 32838.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303521 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-21 23:41:58 +00:00
Davide Italiano
5d18059ccf [NewGVN] Actually check the NewGVN output.
Apparently I messed up squashing two consecutive commits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303516 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-21 20:55:53 +00:00
Davide Italiano
96cb8145e1 [NewGVN] Add a test for non most dominating leader.
Taken from PR32845. Dan removed the most dominating leader check
in r303443, but we check this test anyway to make sure things
don't regress.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303515 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-21 20:50:16 +00:00
Davide Italiano
204f8c0a24 [NewGVN] Create a StoreExpression instead of a VariableExpression.
In the case where we have an operand defined by a lod of the
same memory location. Historically this was a VariableExpression
because we wanted to make sure they ended up in the same class,
but if we create the right expression, they end up in the same
class anyway.

Fixes PR32897. Thanks to Dan for the detailed discussion and the
fix suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303475 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-20 00:46:54 +00:00
Daniel Berlin
55d8857f8f NewGVN: Fix PR32838.
This is a complicated bug involving two issues:
1. What do we do with phi nodes when we prove all arguments are not
live?
2. When is it safe to use value leaders to determine if we can ignore
an argumnet?

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303453 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-19 20:22:20 +00:00
Daniel Berlin
c81a193613 Last of the major pieces to NewGVN - yay!
Summary:
NewGVN: Handle equivalence between phi of ops and op of phis.

This makes our GVN mostly-complete. It would be complete, modulo some
deliberate choices we make.  This means it detects roughly all herband
equivalences in polynomial time, including cases notoriously hard for
other GVN's to detect.  It also detects a very large swath of the
cases we currently rely on instcombine to detect that involve folding
upwards through phis.

Fixes PR 31125, 31463, PR 31868

Reviewers: davide

Subscribers: Prazek, llvm-commits

Differential Revision: https://reviews.llvm.org/D32151

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303444 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-19 19:01:27 +00:00
Davide Italiano
bd8c7210cd [NewGVN] Delete the old store when we find congruent to a load.
(or non-store, more in general). Fixes PR33086. Caught by the
store verifier.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303406 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-19 04:06:10 +00:00
Davide Italiano
ed2b8bd9f4 [NewGVN] Break infinite recursion in singleReachablePHIPath().
We can have cycles between PHIs and this causes singleReachablePhi()
to call itself indefintely (until we run out of stack). The proper
solution would be that of computing SCCs, but it's not worth for
now, so just keep a visited set and give up when we find a cycle.
Thanks to Dan for the discussion/help with this.

Fixes PR33014.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303393 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18 23:22:44 +00:00
Davide Italiano
32baeeab7f [NewGVN] Replace predicate info leftovers.
This time with an additional fix, i.e. we remove the dead
@llvm.ssa.copy instruction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303385 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18 21:43:23 +00:00
Davide Italiano
2c5493bf75 [NewGVN] Re-enable test now that the nondeterminism has been fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303217 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-16 22:27:06 +00:00
Davide Italiano
84be2d3a3b Revert "[NewGVN] Replace predicate info leftovers."
It's breaking the bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303142 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-16 05:51:21 +00:00
Davide Italiano
7c0283272a [NewGVN] Replace predicate info leftovers.
Fixes PR32945.

Differential Revision:  https://reviews.llvm.org/D33226

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303141 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-16 05:23:23 +00:00
Davide Italiano
297d728cd5 [NewGVN] Fix verification of MemoryPhis in verifyMemoryCongruency().
verifyMemoryCongruency() filters out trivially dead MemoryDef(s),
as we find them immediately dead, before moving from TOP to a new
congruence class.
This fixes the same problem for PHI(s) skipping MemoryPhis if all
the operands are dead.

Differential Revision:  https://reviews.llvm.org/D33044

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303100 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-15 18:50:53 +00:00
NAKAMURA Takumi
1c52526318 Disable llvm/test/Transforms/NewGVN/pr32934.ll while Davide is investigating.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302977 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-13 03:05:38 +00:00
Davide Italiano
278c05b970 [NewGVN] XFAIL a flaky test until I find out what's going on.
I bet the change is correct but this test seems to expose some underlying
problem that manifest only on some buildbots, and I'm not able to reproduce
locally. Unfortunately I can't debug right now but I don't want to annoy
people with spurious failures, so I'll XFAIL until I can take a look (over
the weekend).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302976 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-13 02:45:47 +00:00
Davide Italiano
de15f17e31 [NewGVN] Don't incorrectly reset the memory leader.
This code was missing a check for stores, so we were thinking the
congruency class didn't have any memory members, and reset the
memory leader.

Differential Revision:  https://reviews.llvm.org/D33056

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302905 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-12 15:22:45 +00:00
Davide Italiano
9689ee1fa3 [NewGVN] Fix a consistent order for phi nodes operands.
The way we currently define congruency for two PHIExpression(s) is:

1) The operands to the phi functions are congruent
2) The PHIs are defined in the same BasicBlock.

NewGVN works under the assumption that phi operands are in predecessor
order, or at least in some consistent order. OTOH, is valid IR:

patatino:
  %meh = phi i16 [ %0, %winky ], [ %conv1, %tinky ]
  %banana = phi i16 [ %0, %tinky ], [ %conv1, %winky ]
  br label %end

and the in-memory representations of the two SSA registers have an
inconsistent order. This violation of NewGVN assumptions results into
two PHIs found congruent when they're not. While we think it's useful
to have always a consistent order enforced, let's fix this in NewGVN
sorting uses in predecessor order before creating a PHI expression.

Differential Revision:  https://reviews.llvm.org/D32990

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302552 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-09 16:58:28 +00:00
Elad Cohen
ea59a24717 Support arbitrary address space pointers in masked gather/scatter intrinsics.
Fixes PR31789 - When loop-vectorize tries to use these intrinsics for a
non-default address space pointer we fail with a "Calling a function with a
bad singature!" assertion. This patch solves this by adding the 'vector of
pointers' argument as an overloaded type which will determine the address
space.

Differential revision: https://reviews.llvm.org/D31490



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302018 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-03 12:28:54 +00:00
Davide Italiano
f1457bf082 [NewGVN] Don't derive incorrect implications.
In the testcase attached,  we believe %tmp1 implies %tmp4.
where:
  br i1 %tmp1, label %bb2, label %bb7
  br i1 %tmp4, label %bb5, label %bb7

because Wwhile looking at PredicateInfo stuffs we end up calling
isImpliedTrueByMatchingCmp() with the arguments backwards.

Differential Revision:  https://reviews.llvm.org/D32718

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301849 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-01 22:26:28 +00:00
Sanjoy Das
980a21c306 [GVN] Don't coerce non-integral pointers to integers or vice versa
Summary:
See http://llvm.org/docs/LangRef.html#non-integral-pointer-type

The NewGVN test does not fail without these changes (perhaps it does
try to coerce pointers <-> integers to begin with?), but I added the
test case anyway.

Reviewers: dberlin

Subscribers: mcrosier, llvm-commits, Prazek

Differential Revision: https://reviews.llvm.org/D32208

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300730 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 18:21:09 +00:00
Daniel Berlin
c432779417 NewGVN: Don't propagate over phi backedges where undef causes us to
have >1 value, unless we can prove the phi node is cycle free.

Fixes PR 32607.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300299 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 02:53:37 +00:00
Matt Arsenault
bdbe8280f2 Add address space mangling to lifetime intrinsics
In preparation for allowing allocas to have non-0 addrspace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299876 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 20:18:21 +00:00
Daniel Berlin
f634bfbb16 AliasAnalysis: Be less conservative about volatile than atomic.
Summary:
getModRefInfo is meant to answer the question "what impact does this
instruction have on a given memory location" (not even another
instruction).

Long debate on this on IRC comes to the conclusion the answer should be "nothing special".

That is, a noalias volatile store does not affect a memory location
just by being volatile.  Note: DSE and GVN and memdep currently
believe this, because memdep just goes behind AA's back after it says
"modref" right now.

see line 635 of memdep. Prior to this patch we would get modref there, then check aliasing,
and if it said noalias, we would continue.

getModRefInfo *already* has this same AA check, it just wasn't being used because volatile was
lumped in with ordering.

(I am separately testing whether this code in memdep is now dead except for the invariant load case)

Reviewers: jyknight, chandlerc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31726

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299741 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-07 01:28:36 +00:00
Daniel Berlin
a96ab41df7 NewGVN: This patch makes memory congruence work for all types of
memorydefs, not just stores.  Along the way, we audit and fixup issues
about how we were tracking memory leaders, and improve the verifier
to notice more memory congruency issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299682 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06 18:52:50 +00:00
Daniel Berlin
72710465b6 NewGVN: Handle coercion of constant stores, loads, memory insts.
Summary:
Depends on D30928.

This adds support for coercion of stores and memory instructions that do not require insertion to process.
Another few tests down.
I added the relevant tests from rle.ll

Reviewers: davide

Subscribers: llvm-commits, Prazek

Differential Revision: https://reviews.llvm.org/D30929

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299330 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-02 13:23:44 +00:00
Daniel Berlin
fdd2b65197 NewGVN: Fix PR32403 - Handling of undef in phis was not quite correct
due to LLVM's view of phi nodes.  It would cause NewGVN not to fixpoint
in some interesting edge cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298687 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-24 05:30:34 +00:00
Daniel Berlin
174f2f4bda NewGVN: Fix PHI evaluation bug exposed by new verifier. We were checking whether the incoming block was reachable instead of whether the specific edge was reachable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298187 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-18 15:41:36 +00:00
Daniel Berlin
3789b6187c Add missing condprop-xfail.ll that contains the remaining xfail'd tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14 01:46:51 +00:00
Daniel Berlin
f3ed5aafdd NewGVN: We pass rle-nonlocal, we just perform the replacement in a way that keeps the old name instead of the new one
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297683 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-13 22:43:30 +00:00
Daniel Berlin
d7d7be8b3c NewGVN: Rewrite DCE during elimination so we do it as well as old GVN did.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297428 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-10 00:32:33 +00:00
Daniel Berlin
9517d55719 NewGVN: We were not really failing this testcase, because the instructions it was looking for are unused. GVN value numbers unused instructions, NewGVN does not. Fix the instructions to be used, so we eliminate the redundancies it's checking for, and un-XFAIL it
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297058 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-06 20:01:31 +00:00
Igor Laevsky
b89bfffbf9 [BasicAA] Take attributes into account when requesting modref info for a call site
Differential Revision: https://reviews.llvm.org/D29989



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296617 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-01 13:19:51 +00:00
Daniel Berlin
4ddfe6915d PredicateInfo: Support switch statements
Summary:
Depends on D29606 and D29682

Makes us pass GVN's edge.ll (we also will pass a few other testcases
they just need cleaning up).

Thoughts on the Predicate* hiearchy of classes especially welcome :)
(it's not clear to me how best to organize it, and currently, the getBlock* seems ... uglier than maybe wasting a field somewhere or something).

Reviewers: davide

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D29747

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295889 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22 22:20:58 +00:00
Daniel Berlin
072a5a0f52 NewGVN: Start making use of predicateinfo pass.
Summary: This begins using the predicateinfo pass in NewGVN.

Reviewers: davide

Subscribers: llvm-commits, Prazek

Differential Revision: https://reviews.llvm.org/D29682

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295583 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 23:06:50 +00:00
Daniel Berlin
583dfa966f NewGVN: Update a number of xfailed tests to either be correct or note
why they fail.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-12 23:28:06 +00:00
Daniel Berlin
f957e0de79 NewGVN: We really pass TBAA if we enable DCE and fix the test. Note that GVN eliminates no-use readonly/readnone calls, even if they are not marked nounwind. NewGVN only eliminates them if they are marked nounwind, and thus, trivially dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294927 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-12 23:24:47 +00:00