Commit Graph

2135 Commits

Author SHA1 Message Date
Michael Berg
56057ccc17 Utilize new SDNode flag functionality to expand current support for fadd
Summary: This patch originated from D46562 and is a proper subset, with some issues addressed.

Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar

Reviewed By: spatel

Subscribers: wdng, nhaehnle

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334996 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-18 23:44:59 +00:00
Michael Berg
f4fa78a051 Utilize new SDNode flag functionality to expand current support for fma
Summary: This patch originated from D47388 and is a proper subset of the originating changes, containing only the fmf optimization guard extensions.

Reviewers: spatel, hfinkel, wristow, arsenm, javed.absar, rampitec, nhaehnle, nemanjai

Reviewed By: rampitec, nhaehnle

Subscribers: tpr, nemanjai, wdng

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334876 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-16 00:03:06 +00:00
Justin Bogner
3d2940410b Re-apply "[VirtRegRewriter] Avoid clobbering registers when expanding copy bundles"
This is r334750 (which was reverted in r334754) with a fix for an
uninitialized variable that was caught by msan.

Original commit message:
> If a copy bundle happens to involve overlapping registers, we can end
> up with emitting the copies in an order that ends up clobbering some
> of the subregisters. Since instructions in the copy bundle
> semantically happen at the same time, this is incorrect and we need to
> make sure we order the copies such that this doesn't happen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334756 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 19:24:03 +00:00
Justin Bogner
a9f3f668fc Revert "[VirtRegRewriter] Avoid clobbering registers when expanding copy bundles"
There's an msan failure:

  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/19549

This reverts r334750.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334754 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 19:10:57 +00:00
Justin Bogner
a1b4efd4bd [VirtRegRewriter] Avoid clobbering registers when expanding copy bundles
If a copy bundle happens to involve overlapping registers, we can end
up with emitting the copies in an order that ends up clobbering some
of the subregisters. Since instructions in the copy bundle
semantically happen at the same time, this is incorrect and we need to
make sure we order the copies such that this doesn't happen.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334750 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-14 18:32:55 +00:00
Sanjay Patel
7177c61dc9 [DAGCombiner] remove hasOneUse() check from fadd constants transform
We're constant folding here, so we shouldn't check uses. This matches
the IR optimizer behavior.

The x86 test shows the expected win. The AArch64 test shows something
else. This only seems to happen if the "generic" AArch64 CPU model is 
used by MachineCombiner, so I'll file a bug report to follow-up.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334608 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-13 15:22:48 +00:00
Sanjay Patel
dc0e0763cc [AArch64] add tests for fadd with more than one use; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334556 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 22:50:37 +00:00
Petr Hosek
0bf3db8810 [AArch64] Support reserving x20 register
Register x20 is a callee-saved register which may be used for other
purposes in certain contexts, for example to hold special variables
within the kernel. This change adds support for reserving this register
both to frontend and backend to make this register usable for these
purposes.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334531 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 20:00:50 +00:00
Roman Tereshin
b1c42dee78 [MIR][MachineCSE] Implementing proper MachineInstr::getNumExplicitDefs()
Apparently, MachineInstr class definition as well as pretty much all of
the machine passes assume that the only kind of MachineInstr's operands
that is variadic for variadic opcodes is explicit non-definitions.

In particular, this assumption is made by MachineInstr::defs(), uses(),
and explicit_uses() methods, as well as by MachineCSE pass.

The assumption is incorrect judging from at least TableGen backend
implementation, that recognizes variable_ops in OutOperandList, and the
very existence of G_UNMERGE_VALUES generic opcode, or ARM load multiple
instructions, all of which have variadic defs.

In particular, MachineCSE pass breaks MIR with CSE'able G_UNMERGE_VALUES
instructions in it.

This commit implements MachineInstr::getNumExplicitDefs() similar to
pre-existing MachineInstr::getNumExplicitOperands(), fixes
MachineInstr::defs(), uses(), and explicit_uses(), and fixes MachineCSE
pass.

As the issue addressed seems to affect only machine passes that could be
ran mid-GlobalISel pipeline at the moment, the other passes aren't fixed
by this commit, like MachineLICM: that could be done on per-pass basis
when (if ever) they get adopted for GlobalISel.

Reviewed By: arsenm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334520 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 18:30:37 +00:00
Michael Berg
0f51ad9a11 NFC, some additional tests added and some renaming for planned fma support changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334461 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-12 00:52:43 +00:00
Roman Lebedev
300d3c1602 [NFC][X86][AArch64] Reorganize/cleanup BZHI test patterns
Summary:
In D47428, i propose to choose the `~(-(1 << nbits))` as the canonical form of low-bit-mask formation.
As it is seen from these tests, there is a reason for that.

AArch64 currently better handles `~(-(1 << nbits))`, but not the more traditional `(1 << nbits) - 1` (sic!).
The other way around for X86.
It would be much better to canonicalize.

It would seem that there is too much tests, but this is most of all the auto-generated possible variants
of C code that one would expect for BZHI to be formed, and then manually cleaned up a bit.
So this should be pretty representable, which somewhat good coverage...

Related links:
https://bugs.llvm.org/show_bug.cgi?id=36419
https://bugs.llvm.org/show_bug.cgi?id=37603
https://bugs.llvm.org/show_bug.cgi?id=37610
https://rise4fun.com/Alive/idM

Reviewers: javed.absar, craig.topper, RKSimon, spatel

Reviewed By: RKSimon

Subscribers: kristof.beyls, llvm-commits, RKSimon, craig.topper, spatel

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334124 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 19:38:10 +00:00
Evandro Menezes
df07044b5f [AArch64, ARM] Add support for Samsung Exynos M4
Create a separate feature set for Exynos M4 and add test cases.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334115 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 18:56:00 +00:00
David Green
b439319a25 [GlobalMerge] Set the alignment on merged global structs
If no alignment is set, the abi/preferred alignment of structs will be
used which may be higher than required. This can lead to extra padding
and in the end an increase in data size.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334099 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-06 14:48:32 +00:00
Francis Visoiu Mistrih
e70aaf7304 [ShrinkWrap] Add optimization remarks to the shrink-wrapping pass
Start by emitting remarks for very basic unsupported cases such as
irreducible CFGs and EHFunclets. The end goal is to be able to cover all
the cases where we give up with an explanation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333972 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-05 00:27:24 +00:00
Amara Emerson
82441a3e01 [AArch64][GlobalISel] Zero-extend s1 values when returning.
Before we were relying on the any extend of the s1 to s32, but
for AAPCS we need to zero-extend it to at least s8.

Fixes PR36719

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333747 91177308-0d34-0410-b5e6-96231b3b80d8
2018-06-01 13:20:32 +00:00
Luke Geeson
8b391bff9c [AArch64] Reverted rL333427 fixing Clang UnitTest Failure
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333634 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-31 08:27:53 +00:00
Roman Tereshin
7074b82591 [GlobalISel][AArch64] LegalizerInfo verifier: Fixing bugs exposed by LegalizerInfo::verify(...)
Reviewers: aemerson, qcolombet

Reviewed By: qcolombet

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333618 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-31 01:56:05 +00:00
Roman Tereshin
fe061018e7 [GlobalISel][AArch64] LegalizerInfo verifier: Adding LegalizerInfo::verify(...) call w/o fixing bugs
This is to make it clear what kind of bugs the LegalizerInfo::verifier
is able to catch and test its output

Reviewers: aemerson, qcolombet

Reviewed By: aemerson

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333597 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-30 22:10:04 +00:00
Evandro Menezes
ff4e68832f [AArch64] Fix PR32384: bump up the number of stores per memset and memcpy
As suggested in https://bugs.llvm.org/show_bug.cgi?id=32384#c1, this change
makes the inlining of `memset()` and `memcpy()` more aggressive when
compiling for speed.  The tuning remains the same when optimizing for size.

Patch by: Sebastian Pop <s.pop@samsung.com>
          Evandro Menezes <e.menezes@samsung.com>

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333429 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-29 15:58:50 +00:00
Amara Emerson
bfc882d9b5 Revert "[AArch64] added FP16 vcvth intrinsic support"
This reverts commit r333410 due to bot failures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333427 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-29 15:34:22 +00:00
Luke Geeson
5caca234f9 [AArch64] added FP16 vcvth intrinsic support
Summary: Change-Id: I0df845749c7689dfc99150ba7c19c7d0dadbd705

Reviewers: javed.absar, SjoerdMeijer

Reviewed By: SjoerdMeijer

Subscribers: llvm-commits, SjoerdMeijer

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333410 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-29 11:40:33 +00:00
Eli Friedman
3d4c0a0af4 [AArch64] Improve orr+movk sequences for MOVi64imm.
The existing code has three different ways to try to lower a 64-bit
immediate to the sequence ORR+MOVK.  The result is messy: it misses
some possible sequences, and the order of the checks means we sometimes
emit two MOVKs when we only need one.

Instead, just use a simple loop to try all possible two-instruction
ORR+MOVK sequences.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333218 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 19:38:23 +00:00
Geoff Berry
cdedb669f2 [AArch64] Take advantage of variable shift/rotate amount implicit mod operation.
Summary:
Optimize code generated for variable shifts/rotates by taking advantage
of the implicit and/mod done on the variable shift amount register.

Resolves bug 27582 and bug 37421.

Reviewers: t.p.northover, qcolombet, MatzeB, javed.absar

Subscribers: rengolin, kristof.beyls, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-24 18:29:42 +00:00
Eli Friedman
73026bde12 [MachineOutliner] Add "thunk" outlining for AArch64.
When we're outlining a sequence that ends in a call, we can save up to
three instructions in the outlined function by turning the call into
a tail-call. I refer to this as thunk outlining because the resulting
outlined function looks like a thunk; suggestions welcome for a better
name.

In addition to making the outlined function shorter, thunk outlining
allows outlining calls which would otherwise be illegal to outline:
we don't need to save/restore LR, so we don't need to prove anything
about the stack access patterns of the callee.

To make this work effectively, I also added
MachineOutlinerInstrType::LegalTerminator to the generic MachineOutliner
code; this allows treating an arbitrary instruction as a terminator in
the suffix tree.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333015 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-22 19:11:06 +00:00
Sanjay Patel
2f6b67546d [DAG] fold FP binops with undef operands to NaN
This is the FP sibling of D43141 with the corresponding IR change in rL327212.

We can't propagate undef here because if a variable operand is a NaN, these 
binops must propagate NaN. Neither global nor node-level fast-math makes a 
difference. If we have 'nnan', I think later folds can turn the NaN into undef.

The tests in X86/fp-undef.ll are meant to be the definitive verification for 
these folds - everything reduces identically now.

The other test changes are collateral damage. They may need to be altered to
preserve their intent.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332920 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 23:54:19 +00:00
Roman Lebedev
9ed66ee093 [DAGCombine][X86][AArch64] Masked merge unfolding: vector edition.
Summary:
This **appears** to be the last missing piece for the masked merge pattern handling in the backend.

This is [[ https://bugs.llvm.org/show_bug.cgi?id=37104 | PR37104 ]].

[[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]] will introduce an IR canonicalization that is likely bad for the end assembly.
Previously, `andps`+`andnps` / `bsl` would be generated. (see `@out`)
Now, they would no longer be generated  (see `@in`), and we need to make sure that they are generated.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332904 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:41:02 +00:00
Roman Lebedev
6b03aa25cd [X86][AArch64][NFC] Add tests for vector masked merge unfolding
Summary:
This is [[ https://bugs.llvm.org/show_bug.cgi?id=37104 | PR37104 ]].

[[ https://bugs.llvm.org/show_bug.cgi?id=6773 | PR6773 ]] will introduce an IR canonicalization that is likely bad for the end assembly.
Previously, `andps`+`andnps` / `bsl` would be generated. (see `@out`)
Now, they would no longer be generated  (see `@in`).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332903 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-21 21:40:51 +00:00
Haicheng Wu
b508121673 [GlobalMerge] Exit early if only one global is to be merged
To save some compilation time and prevent some unnecessary changes.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332813 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-19 18:00:02 +00:00
Eli Friedman
c7cc20b7d7 [MachineOutliner] Count savings from outlining in bytes.
Counting the number of instructions is both unintuitive and inaccurate.
On AArch64, this only affects the generated remarks and certain rare
pseudo-instructions, but it will have a bigger impact on other targets.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332685 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-18 01:52:16 +00:00
Sanjay Patel
19e6e2d115 [AArch64] preserve test intent by removing undef
We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.

Follow-up to:
https://reviews.llvm.org/rL332534
...because that change wasn't enough.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332636 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-17 18:07:02 +00:00
Sanjay Patel
8aecd6a7a6 [AArch64] preserve test intent by removing undef
We need to clean up the DAG floating-point undef logic.
This process is similar to how we handled integer undef
logic in D43141.

And as we did there, I'm trying to reduce the patch by
changing tests that would probably become meaningless
once we correct FP undef folding.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332534 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 21:57:57 +00:00
Eli Friedman
829baac8ea [MachineOutliner] Don't outline instructions that modify SP.
This breaks the code which saves and restores LR, so we can't outline
without doing something more complicated for stack adjustment.

Found by inspection; we get lucky in most cases because getMemOpInfo
only handles STRWpost, not any other pre/post-increment forms. But it
hits a couple of artificial testcases in the tree.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332529 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 21:20:16 +00:00
Eli Friedman
8458016a40 [MachineOutliner] Don't save/restore LR for tail calls.
The cost computation assumes we do this correctly, but the actual
lowering was wrong.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332514 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 19:49:01 +00:00
Sirish Pande
f9deb98480 [AArch64] Gangup loads and stores for pairing.
Keep loads and stores together (target defines how many loads
and stores to gang up), such that it will help in pairing
and vectorization.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332482 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 15:36:52 +00:00
Amara Emerson
b148259401 [GlobalISel][IRTranslator] Split aggregates during IR translation.
We currently handle all aggregates by creating one large LLT, and letting the
legalizer deal with splitting them up. However using this approach means that
we can't support big endian code correctly.

This patch changes the way that the IRTranslator deals with aggregate values,
by splitting them up into their constituent element values. To do this, parts
of the translator need to be modified to deal with multiple VRegs for a single
Value.

A new Value to VReg mapper is introduced to help keep compile time under
control, currently there is no measurable impact on CTMark despite the extra
code being generated in some cases.

Patch is based on the original work of Tim Northover.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332449 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 10:32:02 +00:00
Peter Smith
b25fd2f921 [AArch64] Support "S" inline assembler constraint
This patch re-introduces the "S" inline assembler constraint. This matches
an absolute symbolic address or a label reference. The primary use case is

asm("adrp %0, %1\n\t"
    "add %0, %0, :lo12:%1" : "=r"(addr) : "S"(&var));

I say re-introduces as it seems like "S" was implemented in the original
AArch64 backend, but it looks like it wasn't carried forward to the merged
backend. The original implementation had A and L modifiers that could be
used to print ":lo12:" to the string. It looks like gcc doesn't use these
and :lo12: is expected to be written in the inline assembly string so I've
not implemented A and L. Clang already supports the S modifier.

Fixes PR37180

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332444 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-16 09:33:25 +00:00
Eli Friedman
b79d2cf940 [MachineOutliner] Add optsize markings to outlined functions.
It doesn't matter much this late in the pipeline, but one place that
does check for it is the function alignment code.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332415 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 23:36:46 +00:00
Evandro Menezes
8d19d135af [AArch64] Improve single vector lane unscaled stores
When storing the 0th lane of a vector, use a simpler and usually more
efficient scalar store instead.  In this case, also using the unscaled
offset.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332394 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 20:41:12 +00:00
Geoff Berry
9b2ede65de [AArch64] Fix mir test case liveins info.
The test case added in r332265 had incomplete livein information which
was caught by the EXPENSIVE_CHECKS bot.  Fix the livein information and
add -verify-machineinstrs to the test case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332367 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 16:27:34 +00:00
Sanjay Patel
f46201df37 [DAG] propagate FMF for all FPMathOperators
This is a simple hack based on what's proposed in D37686, but we can extend it if needed in follow-ups. 
It gets us most of the FMF functionality that we want without adding any state bits to the flags. It 
also intentionally leaves out non-FMF flags (nsw, etc) to minimize the patch.

It should provide a superset of the functionality from D46563 - the extra tests show propagation and 
codegen diffs for fcmp, vecreduce, and FP libcalls.

The PPC log2() test shows the limits of this most basic approach - we only applied 'afn' to the last 
node created for the call. AFAIK, there aren't any libcall optimizations based on the flags currently, 
so that shouldn't make any difference.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332358 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-15 14:16:24 +00:00
Sanjay Patel
26b9bb1166 [AArch64] enhance test to show FMF loss; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332301 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-14 21:53:21 +00:00
Geoff Berry
edf2f13447 [BranchFolding] Allow hoisting to block with a single conditional branch.
Summary:
The BranchFolding pass is currently missing opportunities to hoist
common code if the hoisted-to block contains a single conditional branch
that has register uses.  This occurs somewhat frequently on AArch64 with
CBZ/TBZ opcodes.

This change also eliminates some code differences when debug info is
present since the presence of e.g. DBG_VALUE instructions in the
hoisted-to block can enable hoisting that wouldn't have occurred without
them.

Reviewers: MatzeB, rnk, kparzysz, twoh, aprantl, javed.absar

Subscribers: kristof.beyls, JDevlieghere, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332265 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-14 17:31:18 +00:00
Evandro Menezes
29ab6ce3aa [AArch64] Improve single vector lane stores
When storing the 0th lane of a vector, use a simpler and usually more efficient scalar store instead.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332251 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-14 15:26:35 +00:00
Vedant Kumar
bdb4eca65e [DAGCombiner] Set the right SDLoc on a newly-created sextload (6/N)
This teaches tryToFoldExtOfLoad to set the right location on a
newly-created extload. With that in place, the logic for performing a
certain ([s|z]ext (load ...)) combine becomes identical for sexts and
zexts, and we can get rid of one copy of the logic.

The test case churn is due to dependencies on IROrders inherited from
the wrong SDLoc.

Part of: llvm.org/PR37262

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332118 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-11 18:40:08 +00:00
Geoff Berry
14a7c1a062 [AArch64] Fix performPostLD1Combine to check for constant lane index.
Summary:
performPostLD1Combine in AArch64ISelLowering looks for vector
insert_vector_elt of a loaded value which it can optimize into a single
LD1LANE instruction.  The code checking for the pattern was not checking
if the lane index was a constant which could cause two problems:

- an assert when lowering the LD1LANE ISD node since it assumes an
  constant operand

- an assert in isel if the lane index value depends on the
  post-incremented base register

Both of these issues are avoided by simply checking that the lane index
is a constant.

Fixes bug 35822.

Reviewers: t.p.northover, javed.absar

Subscribers: rengolin, kristof.beyls, mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@332103 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-11 16:25:06 +00:00
Roman Tereshin
051da15b1e [GlobalISel][Legalizer] Widening the second src op of shifts bug fix
The second source operand of G_SHL, G_ASHR, and G_LSHR must preserve its
value as a (small) unsigned integer, therefore its incorrect to widen it
in any way but by zero extending it.

G_SHL was using G_ANYEXT and G_ASHR - G_SEXT (which is correct for their
destination and first source operands, but not the "number of bits to
shift" operand).

Generally, shifts aren't as similar to regular binary operations as it
might seem, for instance, they aren't commutative nor associative and
the second source operand usually requires a special treatment.

Reviewers: bogner, javed.absar, aivchenk, rovka

Reviewed By: bogner

Subscribers: igorb, kristof.beyls, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331926 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 21:43:30 +00:00
Roman Tereshin
f66d8c2e1a Reapplying r331819 [GlobalISel][Legalizer] More concise and faster widenScalar, NFC
The commit was a suspect for clang-cmake-aarch64-global-isel and
    clang-cmake-aarch64-quick bot failures, proved to be innocent.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331898 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 17:28:18 +00:00
Daniel Sanders
e08d6cea34 Revert r331816 and r331820 - [globalisel] Add a combiner helpers for extending loads and use them in a pre-legalize combiner for AArch64
Reverting this to see if the clang-cmake-aarch64-global-isel and
clang-cmake-aarch64-quick bots are failing because of this commit.
We know it wasn't r331819.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331846 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 05:00:17 +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
Roman Tereshin
3ce5bb7fe7 Revert r331819 [GlobalISel][Legalizer] More concise and faster widenScalar, NFC
Reverting this to see if the clang-cmake-aarch64-global-isel and
clang-cmake-aarch64-quick bots are failing because of this commit

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331839 91177308-0d34-0410-b5e6-96231b3b80d8
2018-05-09 01:43:12 +00:00