20690 Commits

Author SHA1 Message Date
Hans Wennborg
fc1247272f Revert r340921 "[NFC] Unify guards detection"
This broke the build, see e.g.

http://lab.llvm.org:8011/builders/clang-cmake-armv8-lnt/builds/4626/
http://lab.llvm.org:8011/builders/clang-ppc64be-linux-lnt/builds/18647/
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-avx2-linux/builds/5856/
http://lab.llvm.org:8011/builders/lld-x86_64-freebsd/builds/22800/

> We have multiple places in code where we try to identify whether or not
> some instruction is a guard. This patch factors out this logic into a separate
> utility function which works uniformly in all places.
>
> Differential Revision: https://reviews.llvm.org/D51152
> Reviewed By: fedor.sergeev

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340923 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 12:21:32 +00:00
Alexandros Lamprineas
65850ba24a [GVNHoist] Re-enable GVNHoist by default
Rebase rL338240 since the excessive memory usage observed when using
GVNHoist with UBSan has been fixed by rL340818.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340922 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 11:58:34 +00:00
Max Kazantsev
68de447e4f [NFC] Unify guards detection
We have multiple places in code where we try to identify whether or not
some instruction is a guard. This patch factors out this logic into a separate
utility function which works uniformly in all places.

Differential Revision: https://reviews.llvm.org/D51152
Reviewed By: fedor.sergeev


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340921 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 11:37:34 +00:00
Max Kazantsev
fe980e2e00 [NFC] Factor out guard utility methods into a separate file
This patch creates file GuardUtils which will contain logic for work with guards
that can be shared across different passes.

Differential Revision: https://reviews.llvm.org/D51151
Reviewed By: fedor.sergeev


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340914 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 10:51:59 +00:00
Hans Wennborg
10a4287278 LoopSink: Don't sink into blocks without an insertion point (PR38462)
In the PR, LoopSink was trying to sink into a catchswitch block, which
doesn't have a valid insertion point.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340900 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-29 06:55:27 +00:00
Zhaoshi Zheng
b9ba94c02a [QTOOL-37352] Consider isLegalAddressingImm in Constant Hoisting
In Thumb1, legal imm range is [0, 255] for ADD/SUB instructions. However, the
legal imm range for LD/ST in (R+Imm) addressing mode is [0, 127]. Imms in
[128, 255] are materialized by mov R, #imm, and LD/STs use them in (R+R)
addressing mode.

This patch checks if a constant is used as offset in (R+Imm), if so, it checks
isLegalAddressingMode passing the constant value as BaseOffset.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340882 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 23:00:59 +00:00
Alina Sbirlea
7729976f77 [SimpleLoopUnswitch] Form dedicated exits after trivial unswitches.
Summary:
Form dedicated exits after trivial unswitches.
Fixes PR38737, PR38283.

Reviewers: chandlerc, fedor.sergeev

Subscribers: sanjoy, jlebar, uabelho, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340871 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 20:41:05 +00:00
Matt Morehouse
0ac1dae46c Revert "[libFuzzer] Port to Windows"
This reverts commit r340860 due to failing tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340867 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 19:07:24 +00:00
Matt Morehouse
0fbff7fa99 [libFuzzer] Port to Windows
Summary:
Port libFuzzer to windows-msvc.
This patch allows libFuzzer targets to be built and run on Windows, using -fsanitize=fuzzer and/or fsanitize=fuzzer-no-link. It allows these forms of coverage instrumentation to work on Windows as well.
It does not fix all issues, such as those with -fsanitize-coverage=stack-depth, which is not usable on Windows as of this patch.
It also does not fix any libFuzzer integration tests. Nearly all of them fail to compile, fixing them will come in a later patch, so libFuzzer tests are disabled on Windows until them.

Patch By: metzman

Reviewers: morehouse, rnk

Reviewed By: morehouse, rnk

Subscribers: morehouse, kcc, eraman

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340860 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:34:32 +00:00
Matt Arsenault
c7c3bec2ff AMDGPU: Remove nan tests in class if src is nnan
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340850 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 18:10:02 +00:00
David Bolvansky
6f1d64eb93 [Inliner] Attribute callsites with inline remarks
Summary:
Sometimes reading an output *.ll file it is not easy to understand why some callsites are not inlined. We can read output of inline remarks (option --pass-remarks-missed=inline) and try correlating its messages with the callsites.

An easier way proposed by this patch is to add to every callsite processed by Inliner an attribute with the latest message that describes the cause of not inlining this callsite. The attribute is called //inline-remark//. By default this feature is off. It can be switched on by the option //-inline-remark-attribute//.

For example in the provided test the result method //@test1// has two callsites //@bar// and inline remarks report different inlining missed reasons:
  remark: <unknown>:0:0: bar not inlined into test1 because too costly to inline (cost=-5, threshold=-6)
  remark: <unknown>:0:0: bar not inlined into test1 because it should never be inlined (cost=never): recursive

It is not clear which remark correspond to which callsite. With the inline remark attribute enabled we get the reasons attached to their callsites:
  define void @test1() {
    call void @bar(i1 true) #0
    call void @bar(i1 false) #2
    ret void
  }
  attributes #0 = { "inline-remark"="(cost=-5, threshold=-6)" }
  ..
  attributes #2 = { "inline-remark"="(cost=never): recursive" }

Patch by: yrouban (Yevgeny Rouban)

Reviewers: xbolva00, tejohnson, apilipenko

Reviewed By: xbolva00, tejohnson

Subscribers: eraman, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340834 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 15:27:25 +00:00
Mikael Holmen
2120ec16b1 [CloneFunction] Constant fold terminators before checking single predecessor
Summary:
This fixes PR31105.

There is code trying to delete dead code that does so by e.g. checking if
the single predecessor of a block is the block itself.

That check fails on a block like this
 bb:
   br i1 undef, label %bb, label %bb
since that has two (identical) predecessors.

However, after the check for dead blocks there is a call to
ConstantFoldTerminator on the basic block, and that call simplifies the
block to
 bb:
   br label %bb

Therefore we now do the call to ConstantFoldTerminator before the check if
the block is dead, so it can realize that it really is.

The original behavior lead to the block not being removed, but it was
simplified as above, and then we did a call to
    Dest->replaceAllUsesWith(&*I);
with old and new being equal, and an assertion triggered.

Reviewers: chandlerc, fhahn

Reviewed By: fhahn

Subscribers: eraman, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340820 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 12:40:11 +00:00
Alexandros Lamprineas
ad2805757e [GVNHoist] Prune out useless CHI insertions
Fix for the out-of-memory error when compiling SemaChecking.cpp
with GVNHoist and ubsan enabled. I've used a cache for inserted
CHIs to avoid excessive memory usage.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340818 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 11:07:54 +00:00
Max Kazantsev
f3a4bc2905 [NFC] A loop can never contain Ret instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340808 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 09:26:28 +00:00
Craig Topper
8e2acb78ca [InstCombine] Extend (add (sext x), cst) --> (sext (add x, cst')) and (add (zext x), cst) --> (zext (add x, cst')) to work for vectors
Differential Revision: https://reviews.llvm.org/D51236

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340796 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-28 02:02:29 +00:00
Sanjay Patel
162b59d303 [InstCombine] fix formatting; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340790 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 23:01:10 +00:00
Sanjay Patel
68bb94af7f [InstCombine] allow shuffle+binop canonicalization with widening shuffles
This lines up with the behavior of an existing transform where if both 
operands of the binop are shuffled, we allow moving the binop before the 
shuffle regardless of whether the shuffle changes the size of the vector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340787 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 22:41:44 +00:00
Evandro Menezes
f494ccf3dd [PATCH] [InstCombine] Fix issue in the simplification of pow() with nested exp{,2}()
Fix the issue of duplicating the call to `exp{,2}()` when it's nested in
`pow()`, as exposed by rL340462.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340784 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 22:11:15 +00:00
George Burgess IV
01bc72d318 s/std::set/DenseSet/; NFC
We only use this set for `insert` and `count`, so a hashing container
seems better here.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340783 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 22:10:59 +00:00
Nico Weber
ee400ed04b fix comment typo
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340744 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 14:25:22 +00:00
Max Kazantsev
4b12e2fa57 [NFC] Split logic of ImplicitControlFlowTracking to allow generalization
We have a class `ImplicitControlFlowTracking` which allows us to keep track of
instructions that can abnormally exit and answer queries like "whether or not
there is side-exiting instruction above this instruction in its block".

We may want to have the similar tracking for other types of "special" instructions,
for example instructions that write memory.

This patch separates ImplicitControlFlowTracking into two classes, isolating all
general logic not related to implicit control flow into its parent class. We can
later make another child of this class to keep track of instructions that write
memory.

The motivation for that is that we want to make these checks efficiently in the
patch https://reviews.llvm.org/D50891.

NOTE: The naming of the parent class is not super cool, but the other options we
have are hardly better. Please feel free to rename it as NFC if you think you've
found a more informative name for it.

Differential Revision: https://reviews.llvm.org/D50954
Reviewed By: fedor.sergeev


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340728 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-27 09:43:16 +00:00
Chandler Carruth
9179aee2c1 [IR] Replace isa<TerminatorInst> with isTerminator().
This is a bit awkward in a handful of places where we didn't even have
an instruction and now we have to see if we can build one. But on the
whole, this seems like a win and at worst a reasonable cost for removing
`TerminatorInst`.

All of this is part of the removal of `TerminatorInst` from the
`Instruction` type hierarchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340701 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 09:51:22 +00:00
Chandler Carruth
acc248f4ab [IR] Sink isExceptional predicate to Instruction, rename it to
`isExceptionalTermiantor` and implement it for opcodes as well following
the common pattern in `Instruction`.

Part of removing `TerminatorInst` from the `Instruction` type hierarchy
to make it easier to share logic and interfaces between instructions
that are both terminators and not terminators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340699 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 08:56:42 +00:00
Chandler Carruth
5eb83c58cd [IR] Begin removal of TerminatorInst by removing successor manipulation.
The core get and set routines move to the `Instruction` class. These
routines are only valid to call on instructions which are terminators.

The iterator and *generic* range based access move to `CFG.h` where all
the other generic successor and predecessor access lives. While moving
the iterator here, simplify it using the iterator utilities LLVM
provides and updates coding style as much as reasonable. The APIs remain
pointer-heavy when they could better use references, and retain the odd
behavior of `operator*` and `operator->` that is common in LLVM
iterators. Adjusting this API, if desired, should be a follow-up step.

Non-generic range iteration is added for the two instructions where
there is an especially easy mechanism and where there was code
attempting to use the range accessor from a specific subclass:
`indirectbr` and `br`. In both cases, the successors are contiguous
operands and can be easily iterated via the operand list.

This is the first major patch in removing the `TerminatorInst` type from
the IR's instruction type hierarchy. This change was discussed in an RFC
here and was pretty clearly positive:
http://lists.llvm.org/pipermail/llvm-dev/2018-May/123407.html

There will be a series of much more mechanical changes following this
one to complete this move.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340698 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-26 08:41:15 +00:00
Xinliang David Li
e50e52860b [PGO] add target md5sum in warning message for icall
Differential revision: http://reviews.llvm.org/D51193


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340657 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 21:38:24 +00:00
Philip Reames
93b31da86a [AST] Simplify code minorly using pattern match [NFC]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340638 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 19:13:39 +00:00
David Bolvansky
be41091c14 Revert [Inliner] Attribute callsites with inline remarks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340619 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 16:39:41 +00:00
David Bolvansky
192fe4c1fb [Inliner] Attribute callsites with inline remarks
Summary:
Sometimes reading an output *.ll file it is not easy to understand why some callsites are not inlined. We can read output of inline remarks (option --pass-remarks-missed=inline) and try correlating its messages with the callsites.

An easier way proposed by this patch is to add to every callsite processed by Inliner an attribute with the latest message that describes the cause of not inlining this callsite. The attribute is called //inline-remark//. By default this feature is off. It can be switched on by the option //-inline-remark-attribute//.

For example in the provided test the result method //@test1// has two callsites //@bar// and inline remarks report different inlining missed reasons:
  remark: <unknown>:0:0: bar not inlined into test1 because too costly to inline (cost=-5, threshold=-6)
  remark: <unknown>:0:0: bar not inlined into test1 because it should never be inlined (cost=never): recursive

It is not clear which remark correspond to which callsite. With the inline remark attribute enabled we get the reasons attached to their callsites:
  define void @test1() {
    call void @bar(i1 true) #0
    call void @bar(i1 false) #2
    ret void
  }
  attributes #0 = { "inline-remark"="(cost=-5, threshold=-6)" }
  ..
  attributes #2 = { "inline-remark"="(cost=never): recursive" }

Patch by: yrouban (Yevgeny Rouban)

Reviewers: xbolva00, tejohnson, apilipenko

Reviewed By: xbolva00, tejohnson

Subscribers: eraman, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340618 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 16:28:36 +00:00
Philip Reames
ef0538fd8a [LICM] Hoist an invariant_start out of loops if there are no stores executed before it
Once the invariant_start is reached, we know that no instruction *after* it can modify the memory. So, if we can prove the location isn't read *between entry into the loop and the execution of the invariant_start*, we can execute the invariant_start before entering the loop.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340617 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 16:24:48 +00:00
Florian Hahn
97d7bcd5c0 [Local] Make DoesKMove required for combineMetadata.
This patch makes the DoesKMove argument non-optional, to force people
to think about it. Most cases where it is false are either code hoisting
or code sinking, where we pick one instruction from a set of
equal instructions among different code paths.

Reviewers: dberlin, nlopes, efriedma, davide

Reviewed By: efriedma

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340606 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-24 11:40:04 +00:00
David Bolvansky
8bcab14697 [LoopVectorize][NFCI] Use find instead of count
Summary:
Avoid "count" if possible -> use "find" to check for the existence of keys.

Passed llvm test suite.

Reviewers: fhahn, dcaballe, mkuper, rengolin

Reviewed By: fhahn

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340563 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 18:34:58 +00:00
David Bolvansky
48d2b81f7a [InstCombine] Fold Select with binary op - FP opcodes
Summary:
Follow up for https://reviews.llvm.org/rL339520 and https://reviews.llvm.org/rL338300

Alive:

```
%A = fcmp oeq float %x, 0.0
%B = fadd nsz float %x, %z
%C = select i1 %A, float %B, float %y
=>
%C = select i1 %A, float %z, float %y
----------                                                                      
  %A = fcmp oeq float %x, 0.0
  %B = fadd nsz float %x, %z
  %C = select %A, float %B, float %y
=>
  %C = select %A, float %z, float %y

Done: 1                                                                         
Optimization is correct

%A = fcmp une float %x, -0.0
%B = fadd nsz float %x, %z
%C = select i1 %A, float %y, float %B
=>
%C = select i1 %A, float %y, float %z
----------                                                                      
  %A = fcmp une float %x, -0.0
  %B = fadd nsz float %x, %z
  %C = select %A, float %y, float %B
=>
  %C = select %A, float %y, float %z

Done: 1                                                                         
Optimization is correct
```


Reviewers: spatel, lebedev.ri

Reviewed By: spatel

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340538 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 15:22:15 +00:00
Brian Homerding
7aa61615de [FunctionAttrs] Infer WriteOnly Function Attribute
These changes expand the FunctionAttr logic in order to mark functions as
WriteOnly when appropriate. This is done through an additional bool variable
and extended logic.

Reviewers: hfinkel, jdoerfert

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340537 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 15:05:22 +00:00
John Brawn
3660992499 [GVN] Invalidate cached info for phis when setting dead predecessors to undef
When GVN sets the incoming value for a phi to undef because the incoming block
is unreachable it needs to also invalidate the cached info for that phi in
MemoryDependenceAnalysis, otherwise later queries will return stale information.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340529 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 12:48:17 +00:00
Florian Hahn
2234b901e1 [SCCP] Remove unused variable added in r340525.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340526 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 11:17:59 +00:00
Florian Hahn
dcf21c6fd1 Recommit r333268: [IPSCCP] Use PredicateInfo to propagate facts from cmp instructions.
This version of the patch fixes cleaning up ssa_copy intrinsics, so it does not
crash for instructions in blocks that have been marked unreachable.

This patch updates IPSCCP to use PredicateInfo to propagate
facts to true branches predicated by EQ and to false branches
predicated by NE.

As a follow up, we should be able to extend it to also propagate additional
facts about nonnull.

Reviewers: davide, mssimpso, dberlin, efriedma

Reviewed By: davide, dberlin

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340525 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 11:04:00 +00:00
Alexander Richardson
47ff67b78d Allow creating llvm::Function in non-zero address spaces
Most users won't have to worry about this as all of the
'getOrInsertFunction' functions on Module will default to the program
address space.

An overload has been added to Function::Create to abstract away the
details for most callers.

This is based on https://reviews.llvm.org/D37054 but without the changes to
make passing a Module to Function::Create() mandatory. I have also added
some more tests and fixed the LLParser to accept call instructions for
types in the program address space.

Reviewed By: bjope

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340519 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 09:25:17 +00:00
David Bolvansky
0130b6e98a [LibCalls] Added returned attribute to libcalls
Reviewers: efriedma

Reviewed By: efriedma

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340512 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-23 05:18:23 +00:00
Evandro Menezes
2898554fda [NFC] Refactor simplification of pow()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340476 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 23:18:02 +00:00
Alina Sbirlea
2e8575cb46 Update MemorySSA in LoopSimplifyCFG.
Summary:
Add MemorySSA as a dependency to LoopSimplifyCFG and preserve it.
Disabled by default until all passes preserve MemorySSA.

Reviewers: bogner, chandlerc

Subscribers: sanjoy, jlebar, Prazek, george.burgess.iv, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340445 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 20:10:21 +00:00
Alina Sbirlea
8093c81ae5 Update MemorySSA in LoopInstSimplify.
Summary:
Add MemorySSA as a depency to LoopInstInstSimplify and preserve it.
Disabled by default until all passes preserve MemorySSA.

Reviewers: chandlerc

Subscribers: sanjoy, jlebar, Prazek, george.burgess.iv, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340444 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 20:05:21 +00:00
Max Kazantsev
f18632847b [GuardWidening] Ignore guards with trivial conditions
Guard widening should not spend efforts on dealing with guards with trivial true/false conditions.
Such guards can easily be eliminated by any further cleanup pass like instcombine. However we
should not unconditionally delete them because it may be profitable to widen other conditions
into such guards.

Differential Revision: https://reviews.llvm.org/D50247
Reviewed By: fedor.sergeev


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340381 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-22 02:40:49 +00:00
Alina Sbirlea
e70c48dc36 Update MemorySSA in BasicBlockUtils.
Summary:
Extend BasicBlocksUtils to update MemorySSA.

Subscribers: sanjoy, arsenm, nhaehnle, jlebar, Prazek, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340365 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 23:32:03 +00:00
Marcello Maggioni
21c21a0782 [LICM] Refactor some AliasSetTracker code to get rid of new/deletes. NFC
Differential Revision: https://reviews.llvm.org/D51024

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340333 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 20:30:14 +00:00
Florian Hahn
bfa8bdbeb4 [CodeExtractor] Use 'normal destination' BB as insert point to store invoke results.
Currently CodeExtractor tries to use the next node after an invoke to
place the store for the result of the invoke, if it is an out parameter
of the region. This fails, as the invoke terminates the current BB.
In that case, we can place the store in the 'normal destination' BB, as
the result will only be available in that case.


Reviewers: davidxl, davide, efriedma

Reviewed By: davidxl

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340331 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 20:07:46 +00:00
Craig Topper
2f00acbb71 [InstCombine] Pull simple checks above a more complicated one. NFCI
I'm assuming its easier to make sure the RHS of an XOR is all ones than it is to check for the many select patterns we have. So lets check that first. Same with the one use check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340321 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 19:17:00 +00:00
Florian Hahn
8be8c4ddf6 [GVN] Assign new value number to calls reading memory, if there is no MemDep info.
Currently we assign the same value number to two calls reading the same
memory location if we do not have MemoryDependence info. Without MemDep
Info we cannot guarantee that there is no store between the two calls, so we
have to assign a new number to the second call.

It also adds a new option EnableMemDep to enable/disable running
MemoryDependenceAnalysis and also renamed NoLoads to NoMemDepAnalysis to
be more explicit what it does. As it also impacts calls that read memory,
NoLoads is a bit confusing.

Reviewers: efriedma, sebpop, john.brawn, wmi

Reviewed By: efriedma

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340319 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 19:11:27 +00:00
Philip Reames
0ff071a16e [AST] Remove notion of volatile from alias sets [NFCI]
Volatility is not an aliasing property. We used to model volatile as if it had extremely conservative aliasing implications, but that hasn't been true for several years now. So, it doesn't make sense to be in AliasSet.

It also turns out the code is entirely a noop. Outside of the AST code to update it, there was only one user: load store promotion in LICM. L/S promotion doesn't need the check since it walks all the users of the address anyway. It already checks each load or store via !isUnordered which causes us to bail for volatile accesses. (Look at the lines immediately following the two remove asserts.)

There is the possibility of some small compile time impact here, but the only case which will get noticeably slower is a loop with a large number of loads and stores to the same address where only the last one we inspect is volatile. This is sufficiently rare it's not worth optimizing for..



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340312 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 17:59:11 +00:00
Craig Topper
01ee4bc183 [BypassSlowDivision] Teach bypass slow division not to interfere with div by constant where constants have been constant hoisted, but not moved from their basic block
DAGCombiner doesn't pay attention to whether constants are opaque before doing the div by constant optimization. So BypassSlowDivision shouldn't introduce control flow that would make DAGCombiner unable to see an opaque constant. This can occur when a div and rem of the same constant are used in the same basic block. it will be hoisted, but not leave the block.

Longer term we probably need to look into the X86 immediate cost model used by constant hoisting and maybe not mark div/rem immediates for hoisting at all.

This fixes the case from PR38649.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340303 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 17:15:33 +00:00
Anna Thomas
099d4ece4f [LV] Vectorize loops where non-phi instructions used outside loop
Summary:
Follow up change to rL339703, where we now vectorize loops with non-phi
instructions used outside the loop. Note that the cyclic dependency
identification occurs when identifying reduction/induction vars.

We also need to identify that we do not allow users where the PSCEV information
within and outside the loop are different. This was the fix added in rL307837
for PR33706.

Reviewers: Ayal, mkuper, fhahn

Subscribers: javed.absar, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340278 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-21 14:40:27 +00:00