Commit Graph

205 Commits

Author SHA1 Message Date
Cameron McInally
aeafce5719 [NFC][Reassociate] Add unary FNeg tests to fast-ReassociateVector.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364232 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-24 21:36:09 +00:00
Cameron McInally
d326b55fd2 [Reassociate] Remove bogus assert reported in PR42349.
Also, add a FIXME for the unsafe transform on a unary FNeg. A unary FNeg can only be transformed to a FMul by -1.0 when the nnan flag is present. The unary FNeg project is a WIP, so the unsafe transformation is acceptable until that work is complete.

The bogus assert with introduced in D63445.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363998 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-20 23:03:55 +00:00
Cameron McInally
180b54534e [Reassociate] Handle unary FNeg in the Reassociate pass
Differential Revision: https://reviews.llvm.org/D63445

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363813 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-19 14:59:14 +00:00
Cameron McInally
9c197ebb5f [NFC][Reassociate] Fix mistake in 468b2ad
Missed 2 'fast fsub(0.0,X) -> fneg(X)' changes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362631 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-05 18:50:07 +00:00
Cameron McInally
5cb5321414 [NFC][Reassociate] Add unary fneg tests to fast-basictest.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362630 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-05 18:35:54 +00:00
Cameron McInally
3c12564f19 [NFC][Reassociate] Regenerate CHECKs for fast-basictest.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@362627 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-05 18:00:27 +00:00
Reid Kleckner
b0b0275b40 Fix new reassociate-catchswitch.ll test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360279 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-08 18:39:03 +00:00
David Greene
a44ee671df [Reassociation] Place moved instructions after landing pads
Reassociation's NegateValue moved instructions to the beginning of
blocks (after PHIs) without checking for exception handling pads.
It's possible for reassociation to move something into an exception
handling block so we need to make sure we don't move things too early
in the block.  This change advances the insertion point past any
exception handling pads.

If the block we want to move into contains a catchswitch, we cannot
move into it.  In that case just create a new neg as if we had not
found an existing neg to move.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360262 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-08 15:44:24 +00:00
Cameron McInally
ed1ec3ab25 Add FNeg IR constant folding support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359982 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-05 16:07:09 +00:00
Eric Christopher
598198edbc Revert "Temporarily Revert "Add basic loop fusion pass.""
The reversion apparently deleted the test/Transforms directory.

Will be re-reverting again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358552 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-17 04:52:47 +00:00
Eric Christopher
02cc44c1b9 Temporarily Revert "Add basic loop fusion pass."
As it's causing some bot failures (and per request from kbarton).

This reverts commit r358543/ab70da07286e618016e78247e4a24fcb84077fda.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358546 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-17 02:12:23 +00:00
Daniel Sanders
b1aec70893 Fix non-determinism in Reassociate caused by address coincidences
Summary:
Between building the pair map and querying it there are a few places that
erase and create Values. It's rare but the address of these newly created
Values is occasionally the same as a just-erased Value that we already
have in the pair map. These coincidences should be accounted for to avoid
non-determinism.

Thanks to Roman Tereshin for the test case.

Reviewers: rtereshin, bogner

Reviewed By: rtereshin

Subscribers: mgrang, llvm-commits

Tags: #llvm

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@356803 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 20:16:35 +00:00
Sanjay Patel
40bfd6fe1e [PatternMatch] Handle undef vectors consistently
This patch fixes the issue noticed in D54532. 
The problem is that cst_pred_ty-based matchers like m_Zero() currently do not match 
scalar undefs (as expected), but *do* match vector undefs. This may lead to optimization 
inconsistencies in rare cases.

There is only one existing test for which output changes, reverting the change from D53205. 
The reason here is that vector fsub undef, %x is no longer matched as an m_FNeg(). While I 
think that the new output is technically worse than the previous one, it is consistent with 
scalar, and I don't think it's really important either way (generally that undef should have 
been folded away prior to reassociation.)

I've also added another test case for this issue based on InstructionSimplify. It took some 
effort to find that one, as in most cases undef folds are either checked first -- and in the 
cases where they aren't it usually happens to not make a difference in the end. This is the 
only case I was able to come up with. Prior to this patch the test case simplified to undef 
in the scalar case, but zeroinitializer in the vector case.

Patch by: @nikic (Nikita Popov)

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347318 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-20 16:08:19 +00:00
Cameron McInally
31fda7550e [FPEnv] Convert more BinaryOperator::isFNeg(...) to m_FNeg(...)
This work is to avoid regressions when we seperate FNeg from the FSub IR instruction. 

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345146 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-24 14:45:18 +00:00
Sanjay Patel
1a72ab0867 [Reassociate] replace fake binop queries with 'match' API
We need to update this code before introducing an 'fneg' instruction in IR,
so we might as well kill off the integer neg/not queries too.

This is no-functional-change-intended for scalar code and most vector code. 
For vectors, we can see that the 'match' API allows for undef elements in 
constants, so we optimize those cases better.

Ideally, there would be a test for each code diff, but I don't see evidence
of that for the existing code, so I didn't try very hard to come up with new 
vector tests for each code change.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@345042 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 15:55:06 +00:00
Sanjay Patel
8f75264f16 [Reassociate] remove bogus tests; NFC
I was trying to provide test coverage for D53533 
with rL344964, but these don't do it...and I don't
think they add any value, so deleting.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344969 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 22:50:27 +00:00
Sanjay Patel
5528b0e484 [Reassociate] add vector tests with undef elements; NFC
Also, regenerate checks for these files. We should do better
on the vector tests by using the PatternMatch API instead of
BinaryOperator::isNot/isNeg.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344964 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 22:04:13 +00:00
Sanjay Patel
59630cbb0a revert r341288 - [Reassociate] swap binop operands to increase factoring potential
This causes or exposes indeterminism that is visible in the output of -reassociate.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342083 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-12 21:29:11 +00:00
Sanjay Patel
722ea18b54 [Reassociate] swap binop operands to increase factoring potential
If we have a pair of binops feeding another pair of binops, rearrange the operands so 
the matching pair are together because that allows easy factorization folds to happen 
in instcombine:
((X << S) & Y) & (Z << S) --> ((X << S) & (Z << S)) & Y (reassociation)

--> ((X & Z) << S) & Y (factorize shift from 'and' ops optimization)

This is part of solving PR37098:
https://bugs.llvm.org/show_bug.cgi?id=37098

Note that there's an instcombine version of this patch attached there, but we're trying
to make instcombine have less responsibility to improve compile-time efficiency.

For reasons I still don't completely understand, reassociate does this kind of transform
sometimes, but misses everything in my motivating cases.

This patch on its own is gluing an independent cleanup chunk to the end of the existing 
RewriteExprTree() loop. We can build on it and do something stronger to better order the 
full expression tree like D40049. That might be an alternative to the proposal to add a 
separate reassociation pass like D41574.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@341288 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-02 14:22:54 +00:00
Sanjay Patel
d841b7b37d [Constants] add identity constants for fadd/fmul
As the test diffs show, the current users of getBinOpIdentity()
are InstCombine and Reassociate. SLP vectorizer is a candidate
for using this functionality too (D28907).

The InstCombine shuffle improvements are part of the planned
enhancements noted in D48830.

InstCombine actually has several other uses of getBinOpIdentity() 
via SimplifyUsingDistributiveLaws(), but we don't call that for 
any FP ops. Fixing that might be another part of removing the
custom reassociation in InstCombine that is only done for fadd+fmul.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336215 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-03 17:12:59 +00:00
Sanjay Patel
ef3144ea38 [Reassociate] add tests for binop with identity constant; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-03 16:44:18 +00:00
Sanjay Patel
ed7df98414 [Reassociate] regenerate checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336211 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-03 16:01:41 +00:00
Sanjay Patel
85678535ba [Reassociate] add test for missing FP constant analysis; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336208 91177308-0d34-0410-b5e6-96231b3b80d8
2018-07-03 15:56:04 +00:00
Davide Italiano
b75b6479e7 [Reassociate] Prevent infinite loops when processing PHIs.
Phi nodes can reside in live blocks but one of their incoming
arguments can come from a dead block. Dead blocks and reassociate
don't play nice together. In fact, reassociate performs an RPO
as a first step to avoid processing dead blocks.

The reason why Reassociate might not fixpoint when examining
dead blocks is that the following:

  %xor0 = xor i16 %xor1, undef
  %xor1 = xor i16 %xor0, undef

is perfectly valid LLVM IR (if it appears in a dead block),
so the worklist algorithm keeps pushing the two instructions for
reexamination. Note that this is not Reassociate fault, at least
not entirely. It's llvm that has a weird definition of dominance.

Fixes PR37390.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332100 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-11 15:45:36 +00:00
Shiva Chen
a8a13bc662 [DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is

!DILabel(scope: !1, name: "foo", file: !2, line: 3)

We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is

llvm.dbg.label(metadata !1)

It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.

We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.

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

Patch by Hsiangkai Wang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331841 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 02:40:45 +00:00
Daniel Sanders
1bfbf81635 [reassociate] Fix excessive revisits when processing long chains of reassociatable instructions.
Summary:
Some of our internal testing detected a major compile time regression which I've
tracked down to:
    r278938 - Revert "Reassociate: Reprocess RedoInsts after each inst".
It appears that processing long chains of reassociatable instructions causes
non-linear (potentially exponential) growth in the number of times an
instruction is revisited. For example, the included test revisits instructions
220 times in a 20-instruction test.

It appears that r278938 reversed the order instructions were visited and that
this is preventing scheduled revisits from being cancelled as a result of
visiting the instructions naturally during normal processing. However, simply
reversing the order also harmed the generated code. Upon closer inspection, it
was discovered that revisits occurred in the opposite order to the first pass
(Thanks to escha for spotting that).

This patch makes the revisit order consistent with the first pass which allows
more revisits to be cancelled. This does appear to have a small impact on the
generated code in few cases but it significantly reduces compile-time.

After this patch, our internal test that was most affected by the regression
dropped from ~2 million revisits to ~4k resulting in Reassociate having 0.46%
of the runtime it had before (99.54% improvement).

Here's the summaries reported by lnt for the LLVM test-suite with --benchmarking-only:
| metric         | geomean before patch | geomean after patch | delta   |
| -----          | -----                | -----               | -----   |
| compile time   | 0.1956               | 0.1261              | -35.54% |
| execution time | 0.3240               | 0.3237              | -       |
| code size      | 7365.4459            | 7365.6079           | -       |

The results have a few wins and losses on compile-time, mostly in the +/- 2.5% range. There was one outlier though:
| Performance Regressions - compile_time | Δ | Previous | Current |
| MultiSource/Benchmarks/ASC_Sequoia/CrystalMk/CrystalMk | 9.82% | 2.0473 | 2.2483 |

Reviewers: javed.absar, dberlin

Reviewed By: dberlin

Subscribers: kristof.beyls, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331381 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-02 17:59:16 +00:00
Sanjay Patel
ae8da5c9b0 [Reassociate] add a test with debug info; NFC
As suggested in D45842 
(although still not sure if we're going to advance that),
we must invalidate references to instructions that have
been recycled (operands were changed, so result is different).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331083 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-27 21:14:15 +00:00
Bjorn Pettersson
925ebe7327 [DebugInfo] Invalidate debug info in ReassociatePass::RewriteExprTree
Summary:
When Reassociate is rewriting an expression tree it may
reuse old binary expression nodes, for new expressions.
Whenever an expression node is reused, but with a non-trivial
change in the result, we need to invalidate any debug info
that is associated with the node.

If for example rewriting
  x = mul a, b
  y = mul c, x
into
  x = mul c, b
  y = mul a, x
we still get the same result for 'y', but 'x' is a new expression.
All debug info referring to 'x' must be invalidated (marked as
optimized out) since we no longer calculate the expected value.

As a side-effect this patch avoid (at least some) problems where
reassociate could end up creating IR with debug-use before def.
Earlier the dbg.value nodes where left untouched in the IR, while
the reused binary nodes where sinked to just before the root node
of the rewritten expression tree. See PR27273 for more info about
such problems.

Reviewers: dblaikie, aprantl, dexonsmith

Reviewed By: aprantl

Subscribers: JDevlieghere, llvm-commits

Tags: #debug-info

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330804 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-25 09:23:56 +00:00
Sanjay Patel
c625656e26 [Reassociate] add baseline tests for binop swapping; NFC
Similar to rL330086, I don't know if we want to do these 
transforms here, but we might as well have the tests
here either way to show that this pass is missing 
potential functionality (intentionally or not).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330368 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-19 21:56:17 +00:00
Warren Ristow
cfa414cb84 [InstCombine] Enable Add/Sub simplifications with only 'reassoc' FMF
These simplifications were previously enabled only with isFast(), but that
is more restrictive than required. Since r317488, FMF has 'reassoc' to
control these cases at a finer level.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330089 91177308-0d34-0410-b5e6-96231b3b80d8
2018-04-14 19:18:28 +00:00
Sanjay Patel
dc22e43bc7 [Reassociate] fix test to be independent of FP undef
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327071 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 22:05:27 +00:00
Sanjay Patel
b70e54f12d [ConstantFold] fp_binop undef, undef --> undef
These are uncontroversial and independent of a proposed LangRef edits (D44216).

I tried to fix tests that would fold away:
rL327004
rL327028
rL327030
rL327034

I'm not sure if the Reassociate tests are meaningless yet, but they probably will be 
as we add more folds, so if anyone has suggestions or wants to fix those, please do.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@327058 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-08 20:42:49 +00:00
Sanjay Patel
49894f8747 [InstCombine] allow fmul fold with less than 'fast'
This is a retry of r326502 with updates to the reassociate 
test file that I missed the first time.

@test15_reassoc in the supposed -reassociate test file 
(except that it tests 2 other passes too...) shows that
there's no clear responsiblity for reassociation transforms.

Instcombine now gets that case, but only because the
constant values are identical. Otherwise, it would still
miss that pattern. 

Reassociate doesn't get that case because it hasn't been 
updated to use less than 'fast' FMF.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326513 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-02 00:14:51 +00:00
Sanjay Patel
d79d6661ee [Reassociate] regenerate checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@326511 91177308-0d34-0410-b5e6-96231b3b80d8
2018-03-01 23:41:03 +00:00
Fiona Glaser
1feb97a12b Reassociate: add global reassociation algorithm
This algorithm (explained more in the source code) takes into account
global redundancies by building a "pair map" to find common subexprs.

The primary motivation of this is to handle situations like

foo = (a * b) * c
bar = (a * d) * c

where we currently don't identify that "a * c" is redundant.

Accordingly, it prioritizes the emission of a * c so that CSE
can remove the redundant calculation later.

Does not change the actual reassociation algorithm -- only the
order in which the reassociated operand chain is reconstructed.

Gives ~1.5% floating point math instruction count reduction on
a large offline suite of graphics shaders.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320515 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-12 19:18:02 +00:00
Sanjay Patel
c7ea0c36fe [Reassociation] regenerate test checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318076 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-13 19:46:28 +00:00
Sanjay Patel
5762a456d4 [Reassociate] add tests with 'reassoc' FMF; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318053 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-13 17:29:11 +00:00
Sanjay Patel
e69c03b3a1 [Reassociate] regenerate test checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317841 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 22:41:39 +00:00
Sanjay Patel
8b45407e72 [Reassociate] auto-generate test checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317819 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 18:26:49 +00:00
Sanjay Patel
114cb60a37 [Reassociate] don't name values "tmp"; NFCI
The toxic stew of created values named 'tmp' and tests that already have
values named 'tmp' and CHECK lines looking for values named 'tmp' causes
bad things to happen in our test line auto-generation scripts because it
wants to use 'TMP' as a prefix for unnamed values. Use less 'tmp' to 
avoid that.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317818 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 18:14:24 +00:00
Sanjay Patel
3b01bb69f0 revert r317809 - [Reassociate] regenerate test checks; NFC
The reassociate pass generates named values such as "%tmp2" which trips up the script's regex's
because the script uses a 'TMP' prefix for unnamed values (%2).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317810 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 16:46:04 +00:00
Sanjay Patel
0e0f70edce [Reassociate] regenerate test checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317809 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 16:35:30 +00:00
Sanjay Patel
60d2d2eec0 [Reassociate] regenerate test checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317806 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 16:30:19 +00:00
Sanjay Patel
c7ddf7c3bc [Reassociate] add check lines; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317805 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 16:25:35 +00:00
Sanjay Patel
7f4962a61a [Reassociate] add tests with 'reassoc' FMF and regenerate checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317804 91177308-0d34-0410-b5e6-96231b3b80d8
2017-11-09 16:23:32 +00:00
Florian Hahn
12b4d06b94 [Reassociate] Remove FIXME from looptest.ll (NFC)
Summary: The loop invariant add (i+j) is reassoicated, I think the FIXME can be removed, because this is what the test case tries to check (AFAIK). I also changed the test to use FileCheck.

Reviewers: mcrosier, davide

Reviewed By: mcrosier, davide

Subscribers: davide, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@317000 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-31 14:06:31 +00:00
Sanjay Patel
7aa4aa680d [Reassociate] auto-generate better checks; NFC
These would fail if the created variable names changed.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315752 91177308-0d34-0410-b5e6-96231b3b80d8
2017-10-13 20:56:35 +00:00
Mikael Holmen
6dbfbe1563 [Reassociate] Do not drop debug location if replacement is missing
Summary:
When reassociating an expression, do not drop the instruction's
original debug location in case the replacement location is
missing.

The debug location must at least not be dropped for inlinable
callsites of debug-info-bearing functions in debug-info-bearing
functions. Failing to do so would result in an "inlinable function "
"call in a function with debug info must have a !dbg location"
error in the verifier.

As preserving the original debug location is not expected
to result in overly jumpy debug line information, it is
preserved for all other cases too.

This fixes PR34231:
https://bugs.llvm.org/show_bug.cgi?id=34231

Original patch by David Stenberg

Reviewers: davide, craig.topper, mcrosier, dblaikie, aprantl

Reviewed By: davide, aprantl

Subscribers: aprantl

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311642 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-24 09:05:00 +00:00
Chad Rosier
37d17304a3 [Reassociate] Don't canonicalize x + (-Constant * y) -> x - (Constant * y)..
..if the resulting subtract will be broken up later.  This can cause us to get
into an infinite loop.

x + (-5.0 * y)      -> x - (5.0 * y)       ; Canonicalize neg const
x - (5.0 * y)       -> x + (0 - (5.0 * y)) ; Break up subtract
x + (0 - (5.0 * y)) -> x + (-5.0 * y)      ; Replace 0-X with X*-1.

PR34078

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311554 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-23 14:10:06 +00:00
Mikael Holmen
029ab41a28 [Reassociate] Make sure EraseInst sets MadeChange
Summary:
EraseInst didn't report that it made IR changes through MadeChange.

It is essential that changes to the IR are reported correctly,
since for example ReassociatePass::run() will indicate that all
analyses are preserved otherwise.
And the CGPassManager determines if the CallGraph is up-to-date
based on status from InstructionCombiningPass::runOnFunction().

Reviewers: craig.topper, rnk, davide

Reviewed By: rnk, davide

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306368 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-27 05:32:13 +00:00