Commit Graph

13608 Commits

Author SHA1 Message Date
Jeremy Morse
e049fdb84b [DebugInfo] Fix pr41175 Dead Store Elimination missing debug loc
Bug: https://bugs.llvm.org/show_bug.cgi?id=41175

In the bug test case the DSE pass is shortening the range of memory that a
memset is working on. A getelementptr is generated so that the new
starting address can be passed to memset. This instruction was not given
a DebugLoc.

To fix the bug, copy the DebugLoc from the memset instruction.

Patch by Orlando Cazalet-Hyams!

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358270 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-12 09:47:35 +00:00
Fangrui Song
a333049e17 [ConstantFold] Don't evaluate FP or FP vector casts or truncations when simplifying icmp
Fix PR41476

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358262 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-12 07:34:30 +00:00
Nikita Popov
6eda2da8e5 [CVP] Generate full test checks for overflows.ll; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358229 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-11 21:10:39 +00:00
Rong Xu
c2c97e63cc [PGO] Better handling of profile hash mismatch
We currently assume profile hash conflicts will be caught by an upfront
check and we assert for the cases that escape the check. The assumption
is not always true as there are chances of conflict. This patch prints
a warning and skips annotating the function for the escaped cases,.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358225 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-11 20:54:17 +00:00
Simon Pilgrim
ce2b63cf70 [ConstantFold] ExtractConstantBytes - handle shifts on large integer types
Use APInt instead of getZExtValue from the ConstantInt until we can confirm that the shift amount is in range.

Reduced from OSS-Fuzz #14169 - https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=14169

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358192 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-11 16:39:31 +00:00
Erik Pilkington
f78c27b74d Fix a hang when lowering __builtin_dynamic_object_size
If the ObjectSizeOffsetEvaluator fails to fold the object size call, then it may
litter some unused instructions in the function. When done repeatably in
InstCombine, this results in an infinite loop. Fix this by tracking the set of
instructions that were inserted, then removing them on failure.

rdar://49172227

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358146 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 23:42:11 +00:00
Nikita Popov
bea42108cf [InstCombine] Handle ssubo always overflow
Following D60483 and D60497, this adds support for AlwaysOverflows
handling for ssubo. This is the last case we can handle right now.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358100 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 16:32:15 +00:00
Nikita Popov
7604f64a6f [InstCombine] ssubo X, C -> saddo X, -C
ssubo X, C is equivalent to saddo X, -C. Make the transformation in
InstCombine and allow the logic implemented for saddo to fold prior
usages of add nsw or sub nsw with constants.

Patch by Dan Robertson.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358099 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 16:27:36 +00:00
Nikita Popov
84db5e0028 [InstCombine] Handle saddo always overflow
Followup to D60483: Handle AlwaysOverflow conditions for saddo as
well.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358095 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 16:18:01 +00:00
David Stenberg
4fb7727e0d Add REQUIRES: asserts to test using -debug-only
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358057 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 08:44:57 +00:00
Florian Hahn
9928b761ce [VPLAN] Minor improvement to testing and debug messages.
1. Use computed VF for stress testing.
2. If the computed VF does not produce vector code (VF smaller than 2), force VF to be 4.
3. Test vectorization of i64 data on AArch64 to make sure we generate VF != 4 (on X86 that was already tested on AVX).

Patch by Francesco Petrogalli <francesco.petrogalli@arm.com>

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358056 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 08:17:28 +00:00
Nikita Popov
b8b80606ab [InstCombine] Handle usubo always overflow
Check AlwaysOverflow condition for usubo. The implementation is the
same as the existing handling for uaddo and umulo. Handling for saddo
and ssubo will follow (smulo doesn't have the necessary ValueTracking
support).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358052 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 07:10:53 +00:00
Chen Zheng
29ea2070bd [InstCombine] Canonicalize (-X s/ Y) to -(X s/ Y).
Differential Revision: https://reviews.llvm.org/D60395


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358050 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 06:52:09 +00:00
Akira Hatanaka
9eaa79da9e [ObjC][ARC] Convert the retainRV marker that is passed as a named
metadata into a module flag in the auto-upgrader and make the ARC
contract pass read the marker as a module flag.

This is needed to fix a bug where ARC contract wasn't inserting the
retainRV marker when LTO was enabled, which caused objects returned
from a function to be auto-released.

rdar://problem/49464214

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358047 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-10 06:20:20 +00:00
Nikita Popov
b182ab7d78 [InstCombine] Add with.overflow always overflow tests; NFC
The uadd and umul cases are currently handled, the usub, sadd, ssub
and smul cases are not. usub, sadd and ssub already have the
necessary ValueTracking support, smul doesn't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358031 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 20:02:23 +00:00
Nikita Popov
338bf21006 Revert "[InstCombine] [InstCombine] Canonicalize (-X s/ Y) to -(X s/ Y)."
This reverts commit 1383a9168948aabfd827220c9445ce0ce5765800.

sdiv-canonicalize.ll fails after this revision. The fold needs to be
moved outside the branch handling constant operands. However when this
is done there are further test changes, so I'm reverting this in the
meantime.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358026 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 18:32:38 +00:00
Nikita Popov
717cc44de6 [ValueTracking] Use computeConstantRange() for signed sub overflow determination
This is the same change as D60420 but for signed sub rather than
signed add: Range information is intersected into the known bits
result, allows to detect more no/always overflow conditions.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358020 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 17:01:49 +00:00
Chen Zheng
c92ab7af6f [InstCombine] [InstCombine] Canonicalize (-X s/ Y) to -(X s/ Y).
Differential Revision: https://reviews.llvm.org/D60395


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358017 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 16:34:31 +00:00
Nikita Popov
d3a2e85cd8 [ValueTracking] Use computeConstantRange() in signed add overflow determination
This is D59386 for the signed add case. The computeConstantRange()
result is now intersected into the existing known bits information,
allowing to detect additional no-overflow/always-overflow conditions
(though the latter isn't used yet).

This (finally...) covers the motivating case from D59071.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358014 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 16:12:59 +00:00
Sanjay Patel
38daa71a61 [InstCombine] prevent possible miscompile with sdiv+negate of vector op
Similar to:
rL358005

Forego folding arbitrary vector constants to fix a possible miscompile bug.
We can enhance the transform if we do want to handle the more complicated
vector case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358013 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 15:13:03 +00:00
Sanjay Patel
3b98d96a7a [InstCombine] add tests for sdiv with negated dividend and constant divisor; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358010 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 14:48:44 +00:00
Sanjay Patel
a5939ccf49 [InstCombine] add tests for sdiv-by-int-min; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358008 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 14:27:07 +00:00
Sanjay Patel
45a2014747 [InstCombine] auto-generate complete test checks; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358007 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 14:27:03 +00:00
Sanjay Patel
30ccf8222e [InstCombine] prevent possible miscompile with negate+sdiv of vector op
// 0 - (X sdiv C)  -> (X sdiv -C)  provided the negation doesn't overflow.

This fold has been around for many years and nobody noticed the potential
vector miscompile from overflow until recently...
So it seems unlikely that there's much demand for a vector sdiv optimization
on arbitrary vector constants, so just limit the matching to splat constants
to avoid the possible bug.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358005 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 14:09:06 +00:00
Sanjay Patel
81527b31ce [InstCombine] add tests/comments for negate+sdiv; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358003 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 13:41:29 +00:00
Chen Zheng
6ea7e45023 [InstCombine] add more testcases for canonicalize (-X s/ Y) to -(X s/ Y).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358000 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-09 12:47:29 +00:00
Sanjay Patel
c7c71947e5 [InstCombine] add tests for negate+sdiv; NFC
PR41425:
https://bugs.llvm.org/show_bug.cgi?id=41425

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357953 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 22:55:10 +00:00
Sanjay Patel
44ffd2ca9e [InstCombine] peek through fdiv to find a squared sqrt
A more general canonicalization between fdiv and fmul would not
handle this case because that would have to be limited by uses
to prevent 2 values from becoming 3 values:
(x/y) * (x/y) --> (x*x) / (y*y)

(But we probably should still have that limited -- but more general --
canonicalization independently of this change.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357943 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 21:23:50 +00:00
Sanjay Patel
5b6d7be67c [InstCombine] add extra-use tests for fmul+sqrt; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357939 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 20:37:34 +00:00
Nikita Popov
c924f5a32a [InstCombine] Add more tests for signed saturing math overflow; NFC
Overflow conditions for sadd.sat and ssub.sat which can be determined
based on constant ranges, but not necessarily known bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357938 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 20:02:47 +00:00
Brian M. Rzycki
954fc5a625 [JumpThreading] Fix incorrect fold conditional after indirectbr/callbr
Fixes bug 40992: https://bugs.llvm.org/show_bug.cgi?id=40992

There is potential for miscompiled code emitted from JumpThreading when
analyzing a block with one or more indirectbr or callbr predecessors. The
ProcessThreadableEdges() function incorrectly folds conditional branches
into an unconditional branch.

This patch prevents incorrect branch folding without fully pessimizing
other potential threading opportunities through the same basic block.

This IR shape was manually fed in via opt and is unclear if clang and the
full pass pipeline will ever emit similar code shapes.

Thanks to Matthias Liedtke for the bug report and simplified IR example.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357930 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 18:20:35 +00:00
Sanjay Patel
f2bfd1e2c6 [InstCombine] remove overzealous assert for shuffles (PR41419)
As the TODO indicates, instsimplify could be improved.

Should fix:
https://bugs.llvm.org/show_bug.cgi?id=41419

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357910 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 13:28:29 +00:00
Simon Pilgrim
f9c39ac584 [InstCombine][X86] Expand MOVMSK to generic IR (PR39927)
First step towards removing the MOVMSK intrinsics completely - this patch expands MOVMSK to the pattern:

e.g. PMOVMSKB(v16i8 x):
%cmp = icmp slt <16 x i8> %x, zeroinitializer
%int = bitcast <16 x i8> %cmp to i16
%res = zext i16 %int to i32

Which is correctly handled by ISel and FastIsel (give or take an annoying movzx move....): https://godbolt.org/z/rkrSFW

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357909 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 13:17:51 +00:00
Chen Zheng
ef1e756a76 [InstCombine] sdiv exact flag fixup.
Differential Revision: https://reviews.llvm.org/D60396


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357904 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 12:08:03 +00:00
Chen Zheng
6d282cdcde [InstCombine] add more testcases for sdiv exact flag fixup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357894 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 09:19:42 +00:00
Chen Zheng
c7a2fabb48 [InstCombine] add testcases for sdiv exact flag fixing - NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357884 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 05:49:15 +00:00
Chen Zheng
86fa8f4d56 [InstCombine]add testcase for sdiv canonicalizetion - NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357883 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-08 03:07:32 +00:00
Nikita Popov
cdee3b7f23 Reapply [ValueTracking] Support min/max selects in computeConstantRange()
Add support for min/max flavor selects in computeConstantRange(),
which allows us to fold comparisons of a min/max against a constant
in InstSimplify. This fixes an infinite InstCombine loop, with the
test case taken from D59378.

Relative to the previous iteration, this contains some adjustments for
AMDGPU med3 tests: The AMDGPU target runs InstSimplify prior to codegen,
which ends up constant folding some existing med3 tests after this
change. To preserve these tests a hidden -amdgpu-scalar-ir-passes option
is added, which allows disabling scalar IR passes (that use InstSimplify)
for testing purposes.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357870 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-07 17:22:16 +00:00
Sanjay Patel
ea127b9f94 [InstCombine] add more tests for fmul+fdiv+sqrt; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357816 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-05 20:54:35 +00:00
Sanjay Patel
995935b43b [InstCombine] add tests for fdiv+fmul; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357782 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-05 17:00:57 +00:00
Sanjay Patel
2ad261a692 [InstCombine] add tests for sqrt+fdiv+fmul; NFC
Examples based on recent llvm-dev thread. These are specific
patterns of more general enhancements that would solve these.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357780 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-05 16:52:57 +00:00
Sanjay Patel
9a81f025cf [InstCombine] add test to show reassociation that creates a denormal constant; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357776 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-05 16:42:21 +00:00
Simon Pilgrim
4fbffbd5f6 [SLP][X86] Regenerate operandorder tests with arguments on same line. NFCI.
Stops update_test_checks.py from splitting the later arguments after the CHECKs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357679 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-04 09:31:12 +00:00
Luqman Aden
0f925da273 [InstCombine] Combine no-wrap sub and icmp w/ constant.
Teach InstCombine the transformation `(icmp P (sub nuw|nsw C2, Y), C) -> (icmp swap(P) Y, C2-C)`

Reviewers: majnemer, apilipenko, sanjoy, spatel, lebedev.ri

Reviewed By: lebedev.ri

Subscribers: dmgreen, lebedev.ri, nikic, hiraditya, JDevlieghere, jfb, jdoerfert, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357674 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-04 07:08:30 +00:00
David L. Jones
a8e2ae4a63 Revert r357452 - 'SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)'
This revision causes tests to fail under ASAN. Since the cause of the failures
is not clear (could be ASAN, could be a Clang bug, could be a bug in this
revision), the safest course of action seems to be to revert while investigating.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357667 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-04 02:27:57 +00:00
Taewook Oh
172ff13310 [ProfileSummary] Count callsite samples when computing total samples.
Summary: Currently ProfileSummaryBuilder doesn't count into callsite samples when computing total samples. Considering that ProfileSummaryInfo is used to checked the hotness of not only body samples but also callsite samples (from SampleProfileLoader), I think the callsite sample counts should be considered when computing total samples.

Reviewers: eraman, danielcdh, wmi

Subscribers: hiraditya, jdoerfert, llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357627 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 19:54:43 +00:00
David Bolvansky
1e8e0fd0ea [InstCombine] Simplify ctpop with bitreverse/bswap
Summary: Fixes PR41337

Reviewers: spatel

Reviewed By: spatel

Subscribers: llvm-commits

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357564 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 08:08:44 +00:00
Matt Arsenault
cd3a8dda10 AMDGPU: Assume ECC is enabled by default if supported
The test should really be checking for the property directly in the
code object headers, but there are problems with this. I don't see
this directly represented in the text form, and for the binary
emission this is depending on a function level subtarget feature to
emit a global flag.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357558 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 01:58:57 +00:00
Matt Arsenault
45c5050e90 InstSimplify: Fold round intrinsics from sitofp/uitofp
https://godbolt.org/z/gEMRZb

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357549 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:25:06 +00:00
David Bolvansky
979d67d952 [InstCombine] Added tests for PR41337
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357522 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 20:21:26 +00:00