Commit Graph

20415 Commits

Author SHA1 Message Date
Marcello Maggioni
33a5d47e0f [GVN] Fix typo in IsValueFullyAvailableInBlock. NFC.
DenseMap insert() method return a pair<iterator, bool>
not pair<iterator, char>
Noticed it and thought I might just fix it ...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339777 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 15:06:53 +00:00
Chijun Sima
0566eefef9 [SimplifyCFG] Remove pointer from SmallPtrSet before deletion
Summary:
Previously, `eraseFromParent()` calls `delete` which invalidates the value of the pointer. Copying the value of the pointer later is undefined behavior in C++11 and implementation-defined (which may cause a segfault on implementations having strict pointer safety) in C++14.

This patch removes the BasicBlock pointer from related SmallPtrSet before `delete` invalidates it in the SimplifyCFG pass.

Reviewers: kuhar, dmgreen, davide, trentxintong

Reviewed By: kuhar, dmgreen

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339773 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 13:56:21 +00:00
David Green
a5f4d29929 [UnJ] Rename hasInvariantIterationCount to hasIterationCountInvariantInParent NFC
This hopefully describes the API of the function more precisely.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339762 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 10:59:41 +00:00
Max Kazantsev
d823f47a68 [NFC] Refactoring of LoopSafetyInfo, step 1
Turn structure into class, encapsulate methods, add clarifying comments.

Differential Revision: https://reviews.llvm.org/D50693
Reviewed By: reames


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339752 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 05:55:43 +00:00
Max Kazantsev
a3bb636475 [NFC] Add sanitizing assertion to ICF tracker
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339751 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 05:50:38 +00:00
Max Kazantsev
7caa753e19 [NFC][LICM] Make hoist method void
Method hoist always returns true. This patch makes it void.

Differential Revision: https://reviews.llvm.org/D50696
Reviewed By: hiraditya


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339750 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 02:49:12 +00:00
Evgeniy Stepanov
6203c9bd08 [hwasan] Add a basic API.
Summary:
Add user tag manipulation functions:
  __hwasan_tag_memory
  __hwasan_tag_pointer
  __hwasan_print_shadow (very simple and ugly, for now)

Reviewers: vitalybuka, kcc

Subscribers: kubamracek, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339746 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-15 00:39:35 +00:00
Matt Morehouse
4db82cd15b [SanitizerCoverage] Add associated metadata to PC guards.
Summary:
Without this metadata LLD strips unused PC table entries
but won't strip unused guards.  This metadata also seems
to influence the linker to change the ordering in the PC
guard section to match that of the PC table section.

The libFuzzer runtime library depends on the ordering
of the PC table and PC guard sections being the same.  This
is not generally guaranteed, so we may need to redesign
PC tables/guards/counters in the future.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: kcc, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339733 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 22:04:34 +00:00
Anna Thomas
a3fdc1d293 NFC: Clarify comment in loop vectorization legality
Clarifying the comment about PSCEV and external IV users by referencing
the bug in question.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339722 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 20:25:13 +00:00
Anna Thomas
1464f16217 [LV] Teach about non header phis that have uses outside the loop
Summary:
This patch teaches the loop vectorizer to vectorize loops with non
header phis that have have outside uses.  This is because the iteration
dependence distance for these phis can be widened upto VF (similar to
how we do for induction/reduction) if they do not have a cyclic
dependence with header phis. When identifying reduction/induction/first
order recurrence header phis, we already identify if there are any cyclic
dependencies that prevents vectorization.

The vectorizer is taught to extract the last element from the vectorized
phi and update the scalar loop exit block phi to contain this extracted
element from the vector loop.

This patch can be extended to vectorize loops where instructions other
than phis have outside uses.

Reviewers: Ayal, mkuper, mssimpso, efriedma

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339703 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 18:22:19 +00:00
Fedor Sergeev
dd807ea799 [Inliner] add inliner stats to new pm version of inliner
Increment existing NumInlined and NumDeleted stats in InlinerPass::run.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339682 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 15:19:14 +00:00
Tomasz Krupa
17454e67ca [X86] Constant folding of adds/subs intrinsics
Summary: This adds constant folding of signed add/sub with saturation intrinsics.

Reviewers: craig.topper, spatel, RKSimon, chandlerc, efriedma

Reviewed By: craig.topper

Subscribers: rnk, llvm-commits

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339659 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 09:04:01 +00:00
Teresa Johnson
d3b60bef64 [ThinLTO] Fix printing of WPD remarks
Summary:
When WPD is performed in a ThinLTO backend, the function may be created
if it isn't already in that module. Module::getOrInsertFunction may
add a bitcast, in which case the returned Constant is not a Function and
doesn't have a name. Invoke stripPointerCasts() on the returned value
where we access its name.

Reviewers: pcc

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339640 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-14 03:00:16 +00:00
Roman Lebedev
f91b41f402 [InstCombine] Re-land: Optimize redundant 'signed truncation check pattern'.
Summary:
This comes with `Implicit Conversion Sanitizer - integer sign change` (D50250):
```
signed char test(unsigned int x) { return x; }
```
`clang++ -fsanitize=implicit-conversion -S -emit-llvm -o - /tmp/test.cpp -O3`
* Old: {F6904292}
* With this patch: {F6904294}

General pattern:
  X & Y

Where `Y` is checking that all the high bits (covered by a mask `4294967168`)
are uniform, i.e.  `%arg & 4294967168`  can be either  `4294967168`  or  `0`
Pattern can be one of:
  %t = add        i32 %arg,    128
  %r = icmp   ult i32 %t,      256
Or
  %t0 = shl       i32 %arg,    24
  %t1 = ashr      i32 %t0,     24
  %r  = icmp  eq  i32 %t1,     %arg
Or
  %t0 = trunc     i32 %arg  to i8
  %t1 = sext      i8  %t0   to i32
  %r  = icmp  eq  i32 %t1,     %arg
This pattern is a signed truncation check.

And `X` is checking that some bit in that same mask is zero.
I.e. can be one of:
  %r = icmp sgt i32   %arg,    -1
Or
  %t = and      i32   %arg,    2147483648
  %r = icmp eq  i32   %t,      0

Since we are checking that all the bits in that mask are the same,
and a particular bit is zero, what we are really checking is that all the
masked bits are zero.
So this should be transformed to:
  %r = icmp ult i32 %arg, 128

The transform itself ended up being rather horrible, even though i omitted some cases.
Surely there is some infrastructure that can help clean this up that i missed?

https://rise4fun.com/Alive/3Ou

The initial commit (rL339610)
was reverted, since the first assert was being triggered.
The @positive_with_extra_and test now has coverage for that case.

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: RKSimon, erichkeane, vsk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339621 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 21:54:37 +00:00
Sanjay Patel
9ee8a957cc [SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds (retry r339608)
Even though this code is below a function called optimizeFloatingPointLibCall(),
we apparently can't guarantee that we're dealing with FPMathOperators, so bail
out immediately if that's not true.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339618 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 21:49:19 +00:00
Roman Lebedev
8244893b61 Revert "[InstCombine] Optimize redundant 'signed truncation check pattern'."
At least one buildbot was able to actually trigger that assert
on the top of the function. Will investigate.

This reverts commit r339610.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339612 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 20:46:22 +00:00
Roman Lebedev
3edbc102dd [InstCombine] Optimize redundant 'signed truncation check pattern'.
Summary:
This comes with `Implicit Conversion Sanitizer - integer sign change` (D50250):
```
signed char test(unsigned int x) { return x; }
```
`clang++ -fsanitize=implicit-conversion -S -emit-llvm -o - /tmp/test.cpp -O3`
* Old: {F6904292}
* With this patch: {F6904294}

General pattern:
  X & Y

Where `Y` is checking that all the high bits (covered by a mask `4294967168`)
are uniform, i.e.  `%arg & 4294967168`  can be either  `4294967168`  or  `0`
Pattern can be one of:
  %t = add        i32 %arg,    128
  %r = icmp   ult i32 %t,      256
Or
  %t0 = shl       i32 %arg,    24
  %t1 = ashr      i32 %t0,     24
  %r  = icmp  eq  i32 %t1,     %arg
Or
  %t0 = trunc     i32 %arg  to i8
  %t1 = sext      i8  %t0   to i32
  %r  = icmp  eq  i32 %t1,     %arg
This pattern is a signed truncation check.

And `X` is checking that some bit in that same mask is zero.
I.e. can be one of:
  %r = icmp sgt i32   %arg,    -1
Or
  %t = and      i32   %arg,    2147483648
  %r = icmp eq  i32   %t,      0

Since we are checking that all the bits in that mask are the same,
and a particular bit is zero, what we are really checking is that all the
masked bits are zero.
So this should be transformed to:
  %r = icmp ult i32 %arg, 128

https://rise4fun.com/Alive/3Ou

Reviewers: spatel, craig.topper

Reviewed By: spatel

Subscribers: RKSimon, erichkeane, vsk, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339610 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 20:33:08 +00:00
Sanjay Patel
6a6b35cd86 revert r339608 - [SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds
Can't set the builder flags without knowing this is an FPMathOperator. I'll add a test
for that and try again.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339609 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 20:20:38 +00:00
Sanjay Patel
6c5927533a [SimplifyLibCalls] don't drop fast-math-flags on trig reflection folds
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339608 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 20:14:27 +00:00
Sanjay Patel
8b80050699 [SimplifyLibCalls] add reflection fold for -sin(-x) (PR38458)
This is a very partial fix for the reported problem. I suspect
we do not get this fold in most motivating cases because most of
the time, the libcall would have been replaced by an intrinsic,
and that optimization is handled elsewhere...but maybe it should
be handled here?


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339604 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 19:24:41 +00:00
Sanjay Patel
3a74b4221a [SimplifyLibCalls] reduce code for optimizeCos; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339588 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 17:40:49 +00:00
Simon Pilgrim
d2f20dd1d7 [InstCombine] Limit simplifyAllocaArraySize constant folding to values that fit into a uint64_t
Fixes OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5223

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339584 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 16:50:20 +00:00
Evandro Menezes
13b933258d [SLC] Expand simplification of pow() for vector types
Also consider vector constants when simplifying `pow()`.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339578 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 16:12:37 +00:00
Max Kazantsev
ffc8c538b7 [GuardWidening] Widen very likely non-taken br instructions
This is a second part of D49974 that handles widening of conditional branches that
have very likely `false` branch.

Differential Revision: https://reviews.llvm.org/D50040
Reviewed By: reames


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339537 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 07:58:19 +00:00
Craig Topper
6145f7d3cf [InstCombine] Fix typo in comment. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339532 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 00:54:23 +00:00
Craig Topper
069f0c31f7 [InstCombine] Replace call to haveNoCommonBitsSet in visitXor with just the special case that doesn't use computeKnownBits.
Summary: computeKnownBits is expensive. The cases that would be detected by the computeKnownBits portion of haveNoCommonBitsSet were already handled by the earlier call to SimplifyDemandedInstructionBits.

Reviewers: spatel, lebedev.ri

Reviewed By: lebedev.ri

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339531 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-13 00:38:27 +00:00
David Bolvansky
9ff5ab2f4e [InstCombine] Fold Select with binary op - non-commutative opcodes
Summary:
Basic version was merged - https://reviews.llvm.org/D49954

This adds support for FP & non-commutative opcodes

Precommited tests: https://reviews.llvm.org/rL338727

Reviewers: spatel, lebedev.ri

Reviewed By: spatel

Subscribers: jfb

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339520 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-12 17:30:07 +00:00
Sanjay Patel
fa0e915a8e [InstCombine] fix/enhance fadd/fsub factorization
(X * Z) + (Y * Z) --> (X + Y) * Z
  (X * Z) - (Y * Z) --> (X - Y) * Z
  (X / Z) + (Y / Z) --> (X + Y) / Z
  (X / Z) - (Y / Z) --> (X - Y) / Z

The existing code that implemented these folds failed to 
optimize vectors, and it transformed code with multiple 
uses when it should not have.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339519 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-12 15:48:26 +00:00
David Green
6fb93f326d [UnJ] Improve explicit loop count checks
Try to improve the computed counts when it has been explicitly set by a pragma
or command line option. This moves the code around, so that first call to
computeUnrollCount to get a sensible count and override that if explicit unroll
and jam counts are specified.

Also added some extra debug messages for when unroll and jamming is disabled.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339501 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-11 07:37:31 +00:00
David Green
d2a6b5951c [UnJ] Create a hasInvariantIterationCount function. NFC
Pulled out a separate function for some code that calculates
if an inner loop iteration count is invariant to it's outer
loop.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339500 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-11 06:57:28 +00:00
JF Bastien
018235abdf Re-commit "[NFC] More ConstantMerge refactoring"
My previous change moved some code upwards which caused an assert in debug mode
because the global value didn't necessarily have an initializer. Don't do that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339485 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 22:41:09 +00:00
Philip Reames
c072330937 [LICM] Hoist assumes out of loops
If we have an assume which is known to execute and whose operand is invariant, we can lift that into the pre-header. So long as we don't change which paths the assume executes on, this is a legal transformation. It's likely to be a useful canonicalization as other transforms only look for dominating assumes.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339481 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 22:21:56 +00:00
JF Bastien
a82514350b Revert "[NFC] More ConstantMerge refactoring"
Sanitizers seem unhappy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339480 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 22:10:20 +00:00
JF Bastien
df25b5d38f [NFC] More ConstantMerge refactoring
This makes my upcoming patch much easier to read.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339478 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 21:58:00 +00:00
Sanjay Patel
c5553c47ec [InstCombine] rearrange code for foldSelectBinOpIdentity; NFCI
This is a retry of rL339439 with a fix for the problem that
caused the original commit to be reverted at rL339446. 

That problem was that the compare can be integer while
the binop is FP or vice-versa, so we need to use the binop 
type when we ask for the identity constant.

A test to guard against the problem was added at rL339453.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339469 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 20:30:35 +00:00
Matt Arsenault
203b8a7809 AMDGPU: Turn class x, p_zero|n_zero into fcmp oeq x, 0
The library does use this for some reason.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339461 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 18:58:49 +00:00
Evgeniy Stepanov
9f42ecf77b [hwasan] Add -hwasan-with-ifunc flag.
Summary: Similar to asan's flag, it can be used to disable the use of ifunc to access hwasan shadow address.

Reviewers: vitalybuka, kcc

Subscribers: srhines, hiraditya, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339447 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 16:21:37 +00:00
Sanjay Patel
395e45dbe5 [InstCombine] revert r339439 - rearrange code for foldSelectBinOpIdentity
That was supposed to be NFC, but it exposed a logic hole somewhere that
caused bots to fail.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339446 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 16:12:19 +00:00
Sanjay Patel
abd8586481 [InstCombine] rearrange code for foldSelectBinOpIdentity; NFCI
This should make it easier to folow and to add the planned enhancements
such as D50190.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339439 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 15:11:26 +00:00
Alexander Potapenko
252445ebb1 [MSan] Shrink the register save area for non-SSE builds
If code is compiled for X86 without SSE support, the register save area
doesn't contain FPU registers, so `AMD64FpEndOffset` should be equal to
`AMD64GpEndOffset`.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339414 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 08:06:43 +00:00
David Bolvansky
af0751b6c0 [InstCombine] Transform str(n)cmp to memcmp
Summary:
Motivation examples:
int strcmp_memcmp() {
    char buf[12];
    return strcmp(buf, "key") == 0;
}

int strcmp_memcmp2() {
    char buf[12];
    return strcmp(buf, "key") != 0;
}

int strncmp_memcmp() {
    char buf[12];
    return strncmp(buf, "key", 3) == 0;
}

can be turned to memcmp.

See test file for more cases.

Reviewers: efriedma

Reviewed By: efriedma

Subscribers: spatel, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339410 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10 04:32:54 +00:00
Matt Arsenault
0904319a62 ValueTracking: Start enhancing isKnownNeverNaN
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339399 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 22:40:08 +00:00
Sanjay Patel
54b09599fc [InstSimplify] move minnum/maxnum with Inf folds from instcombine
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339396 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 22:20:44 +00:00
JF Bastien
01d33f7676 [NFC] ConstantMerge: factor out some functions
This makes the code easier to read and will make an upcoming patch I have easier to review because that patch needed this refactoring to reuse some of the functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339391 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:56:09 +00:00
JF Bastien
9d9ecd48fb ConstantMerge: update MadeChange when change is made
It was always false, which is obviously wrong.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339390 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:36:57 +00:00
Philip Reames
3173bbdb72 [LICM] Suppress a compiler warning noticed by one of the bots
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339388 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 21:15:33 +00:00
Philip Reames
fbcccaf8cc [LICM] hoist fences out of loops w/o memory operations
The motivating case is an otherwise dead loop with a fence in it. At the moment, this goes all the way through the optimizer and we end up emitting an entirely pointless loop on x86. This case may seem a bit contrived, but we've seen it in real code as the result of otherwise reasonable lowering strategies combined w/thread local memory optimizations (such as escape analysis).

To handle this simple case, we can teach LICM to hoist must execute fences when there is no other memory operation within the loop.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339378 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 20:18:42 +00:00
Sanjay Patel
ccbe637eb2 [InstCombine] allow fsub+fmul FMF folds for vectors
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339368 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 18:42:12 +00:00
Alina Sbirlea
2c03a06c9e SCEV should forget all loops containing a deleted block.
Summary:
LoopSimplifyCFG should update ScEv for all loops after a block is deleted.
If the deleted block "Succ" is part of L, then it is part of all parent loops, so forget topmost loop.

Reviewers: greened, mkazantsev, sanjoy

Subscribers: jlebar, javed.absar, uabelho, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339363 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 17:53:26 +00:00
Reid Kleckner
cddb95c7bc [GlobalOpt] Don't apply fastcc if it would break inalloca invariants
The inalloca parameter has to be the only parameter passed in memory.
Changing the convention to fastcc can break that.

At some point we should teach global opt how to optimize ABI attributes
like inalloca and maybe byval. These attributes are mainly used to match
C ABIs. They are harder for LLVM to optimize and they don't always
generate the best code.

Fixes PR38487

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339360 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-09 17:29:26 +00:00