557 Commits

Author SHA1 Message Date
Simon Pilgrim
8b6100048e [X86][MMX] Add fast-isel support for MMX non-temporal writes
Differential Revision: https://reviews.llvm.org/D31754

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299852 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 16:58:07 +00:00
Craig Topper
373055293b [AVX-512] Fix bad comment from r299112. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299114 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30 21:05:33 +00:00
Craig Topper
c1e48aa5eb [AVX-512] Fix another case where fastisel was generating a GR8 to VK1 copy. This time after calls returning i1.
Fixes PR32472.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299112 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30 21:02:52 +00:00
Craig Topper
b032c49e1a [AVX-512] Punt on fast-isel of truncates to i1 when AVX512 is enabled.
We should be masking the value and emitting a register copy like we do in non-fast isel. Instead we were just updating the value map and emitting nothing.

After r298928 we started seeing cases where we would create a copy from GR8 to GR32 because the source register in a VK1 to GR32 copy was replaced by the GR8 going into a truncate.

This fixes PR32451.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298957 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 23:20:37 +00:00
Craig Topper
ee18eb90ff [AVX-512] Fix accidental uses of AH/BH/CH/DH after copies to/from mask registers
We've had several bugs(PR32256, PR32241) recently that resulted from usages of AH/BH/CH/DH either before or after a copy to/from a mask register.

This ultimately occurs because we create COPY_TO_REGCLASS with VK1 and GR8. Then in CopyToFromAsymmetricReg in X86InstrInfo we find a 32-bit super register for the GR8 to emit the KMOV with. But as these tests are demonstrating, its possible for the GR8 register to be a high register and we end up doing an accidental extra or insert from bits 15:8.

I think the best way forward is to stop making copies directly between mask registers and GR8/GR16. Instead I think we should restrict to only copies between mask registers and GR32/GR64 and use EXTRACT_SUBREG/INSERT_SUBREG to handle the conversion from GR32 to GR16/8 or vice versa.

Unfortunately, this complicates fastisel a bit more now to create the subreg extracts where we used to create GR8 copies. We can probably make a helper function to bring down the repitition.

This does result in KMOVD being used for copies when BWI is available because we don't know the original mask register size. This caused a lot of deltas on tests because we have to split the checks for KMOVD vs KMOVW based on BWI.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 16:35:29 +00:00
Craig Topper
53a96f264e [AVX-512] Pre-emptively fix more places in fastisel where we might copy a VK1 register into a AH/BH/CH/DH register.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297704 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-14 04:18:25 +00:00
Craig Topper
85ad85b52e [AVX-512] Fix another case where we are copying from a mask register using AH/BH/CH/DH with fastisel.
Fixes PR32256. Still planning to do an audit for other possible cases.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297678 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-13 21:58:54 +00:00
Craig Topper
2e124a6c7c [AVX-512] Fix a bad use of a high GR8 register after copying from a mask register during fast isel. This ends up extracting from bits 15:8 instead of the lower bits of the mask.
I'm pretty sure there are more problems lurking here. But I think this fixes PR32241.

I've added the test case from that bug and added asserts that will fail if we ever try to copy between high registers and mask registers again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297574 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-12 03:37:37 +00:00
Ayman Musa
5abd133c8d [X86] Fix creating vreg def after use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296601 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-01 10:20:48 +00:00
Ayman Musa
6f30b9797e [X86][AVX] Disable VCVTSS2SD & VCVTSD2SS memory folding and fix the register class of their first input when creating node in fast-isel.
(Quick fix to buildbot failure after rL295940 commit).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295970 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-23 13:15:44 +00:00
Craig Topper
25dd36e1c9 [X86] Remove scalar logical op alias instructions. Just use COPY_FROM/TO_REGCLASS and the normal packed instructions instead
Summary:
This patch removes the scalar logical operation alias instructions. We can just use reg class copies and use the normal packed instructions instead. This removes the need for putting these instructions in the execution domain fixing tables as was done recently.

I removed the loadf64_128 and loadf32_128 patterns as DAG combine creates a narrower load for (extractelt (loadv4f32)) before we ever get to isel.

I plan to add similar patterns for AVX512DQ in a future commit to allow use of the larger register class when available.

Reviewers: spatel, delena, zvi, RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288771 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-06 04:58:39 +00:00
Craig Topper
1fcb0c5274 [X86] Remove unnecessary explicit uses of .SimpleTy just to do an equality comparison. MVT's operator== already takes care of this. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288646 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 06:09:55 +00:00
Craig Topper
a3d4859091 [AVX-512] Teach fast isel to handle 512-bit vector bitcasts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288641 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 05:50:51 +00:00
Craig Topper
9def0bf1c7 [AVX-512] Teach fast isel to use masked compare and movss for handling scalar cmp and select sequence when AVX-512 is enabled. This matches the behavior of normal isel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288636 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-05 04:51:31 +00:00
Peter Collingbourne
06115803f9 IR: Change the gep_type_iterator API to avoid always exposing the "current" type.
Instead, expose whether the current type is an array or a struct, if an array
what the upper bound is, and if a struct the struct type itself. This is
in preparation for a later change which will make PointerType derive from
Type rather than SequentialType.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288458 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-02 02:24:42 +00:00
Zvi Rackover
afe87362c7 [X86][FastISel] Assert that we are dealing with arithmetic with overflow intrinsics. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286961 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-15 13:50:35 +00:00
Zvi Rackover
f042d8480e [X86][FastISel] Fix lowering of overflow result on AVX512 targets
Summary:
    Fix a case where the overflow value of type i1, which is legal on AVX512, was assigned to a VK1 register class.
    We always want this value to be assigned to a GPR since the overflow return value is lowered to a SETO instruction.

    Fixes pr30981.

    Reviewers: mkuper, igorb, craig.topper, guyblank, qcolombet

    Subscribers: qcolombet, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286958 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-15 13:29:23 +00:00
Guy Blank
154ed2a66b [X86][FastISel] Use a COPY from K register to a GPR instead of a K operation
The KORTEST was introduced due to a bug where a TEST instruction used a K register.
but, turns out that the opposite case of KORTEST using a GPR is now happening

The change removes the KORTEST flow and adds a COPY instruction from the K reg to a GPR.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282580 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-28 11:22:17 +00:00
Craig Topper
610e45c3d2 [AVX-512] Teach fastisel load/store handling to use EVEX encoded instructions for 128/256-bit vectors and scalar single/double.
Still need to fix the register classes to allow the extended range of registers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280682 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-05 23:58:40 +00:00
Craig Topper
e8886131cc [X86] Make some static arrays of opcodes const and shrink to uint16_t. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280649 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-05 07:14:21 +00:00
Guy Blank
314286f348 [AVX512][FastISel] Do not use K registers in TEST instructions
In some cases, FastIsel was emitting TEST instruction with K reg input, which is illegal.
Changed to using KORTEST when dealing with K regs.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279393 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-21 08:02:27 +00:00
Justin Bogner
7d7a23e700 Replace a few more "fall through" comments with LLVM_FALLTHROUGH
Follow up to r278902. I had missed "fall through", with a space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278970 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 20:30:52 +00:00
Justin Bogner
6673ea81f6 Replace "fallthrough" comments with LLVM_FALLTHROUGH
This is a mechanical change of comments in switches like fallthrough,
fall-through, or fall-thru to use the LLVM_FALLTHROUGH macro instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278902 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17 05:10:15 +00:00
Matthias Braun
f79c57a412 MachineFunction: Return reference for getFrameInfo(); NFC
getFrameInfo() never returns nullptr so we should use a reference
instead of a pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277017 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-28 18:40:00 +00:00
Nico Weber
2cef100c63 Teach fast isel about the win64 calling convention.
This mostly just works.

Vectorcall rets are still not supported.

The win64_eh test change is because fast isel doesn't use rsi for temporary
computations, so it doesn't need to be pushed. The test case I'm changing was
originally added to test pushes, but by now there are other test cases in that
file exercising that code path.

https://reviews.llvm.org/D22422


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275607 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 20:18:37 +00:00
Nico Weber
cccdd2eff6 Teach fast isel calls and rets about stdcall.
stdcall is callee-pop like thiscall, so the thiscall changes already did most
of the work for this.  This change only opts stdcall in and adds tests.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275414 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 13:54:26 +00:00
Nico Weber
0e9e4ecaa4 Teach fast isel about thiscall (and callee-pop) calls.
http://reviews.llvm.org/D22315


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275360 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-14 01:52:51 +00:00
Nico Weber
a911eddad4 Teach FastISel about thiscall (and, hence, about callee-pop).
http://reviews.llvm.org/D22115


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275135 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-12 01:30:35 +00:00
Elena Demikhovsky
15b950c68f Re-commit of 274613.
The prev commit failed on compilation.
A minor change in one pattern in lib/Target/X86/X86InstrAVX512.td fixes the failure.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274626 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 14:15:43 +00:00
Elena Demikhovsky
f94a00c5b0 Reverted 274613 due to compilation failue.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274615 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 09:11:49 +00:00
Elena Demikhovsky
0a272cb0a0 AVX-512: Optimization for patterns with i1 scalar type
The patch removes redundant kmov instructions (not all, we still have a lot of work here) and redundant "and" instructions after "setcc".
I use "AssertZero" marker between X86ISD::SETCC node and "truncate" to eliminate extra "and $1" instruction.
I also changed zext, aext and trunc patterns in the .td file. It allows to remove extra "kmov" instruictions.

This patch fixes https://llvm.org/bugs/show_bug.cgi?id=28173.

Fast ISEL mode is not supported correctly for AVX-512. ICMP/FCMP scalar instruction should return result in k-reg. It will be fixed in one of the next patches. I redirected handling of "cmp" to the DAG builder mode. (The code looks worse in one specific test case, but without this fix the new patch fails).

Differential revision: http://reviews.llvm.org/D21956



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274613 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-06 09:01:20 +00:00
Rafael Espindola
809018e56e Delete unused includes. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274225 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 12:19:16 +00:00
Duncan P. N. Exon Smith
567409db69 CodeGen: Use MachineInstr& in TargetInstrInfo, NFC
This is mostly a mechanical change to make TargetInstrInfo API take
MachineInstr& (instead of MachineInstr* or MachineBasicBlock::iterator)
when the argument is expected to be a valid MachineInstr.  This is a
general API improvement.

Although it would be possible to do this one function at a time, that
would demand a quadratic amount of churn since many of these functions
call each other.  Instead I've done everything as a block and just
updated what was necessary.

This is mostly mechanical fixes: adding and removing `*` and `&`
operators.  The only non-mechanical change is to split
ARMBaseInstrInfo::getOperandLatencyImpl out from
ARMBaseInstrInfo::getOperandLatency.  Previously, the latter took a
`MachineInstr*` which it updated to the instruction bundle leader; now,
the latter calls the former either with the same `MachineInstr&` or the
bundle leader.

As a side effect, this removes a bunch of MachineInstr* to
MachineBasicBlock::iterator implicit conversions, a necessary step
toward fixing PR26753.

Note: I updated WebAssembly, Lanai, and AVR (despite being
off-by-default) since it turned out to be easy.  I couldn't run tests
for AVR since llc doesn't link with it turned on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274189 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-30 00:01:54 +00:00
David Majnemer
30ef1b33fa Switch more loops to be range-based
This makes the code a little more concise, no functional change is
intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273644 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-24 04:05:21 +00:00
Benjamin Kramer
af18e017d2 Pass DebugLoc and SDLoc by const ref.
This used to be free, copying and moving DebugLocs became expensive
after the metadata rewrite. Passing by reference eliminates a ton of
track/untrack operations. No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272512 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-12 15:39:02 +00:00
Simon Pilgrim
2f401854a1 [X86][SSE] Add general lowering of nontemporal vector loads (fixed bad merge)
Currently the only way to use the (V)MOVNTDQA nontemporal vector loads instructions is through the int_x86_sse41_movntdqa style builtins.

This patch adds support for lowering nontemporal loads from general IR, allowing us to remove the movntdqa builtins in a future patch.

We currently still fold nontemporal loads into suitable instructions, we should probably look at removing this (and nontemporal stores as well) or at least make the target's folding implementation aware that its dealing with a nontemporal memory transaction.

There is also an issue that VMOVNTDQA only acts on 128-bit vectors on pre-AVX2 hardware - so currently a normal ymm load is still used on AVX1 targets.

Differential Review: http://reviews.llvm.org/D20965

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272011 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:47:23 +00:00
Igor Breger
7e0019d8f7 [AVX512] Fix load opcode for fast isel.
Differential Revision: http://reviews.llvm.org/D21067

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272006 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-07 13:08:45 +00:00
Craig Topper
d2ed3fa129 [AVX512] Add 512-bit load/stores to fast isel.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271486 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 04:51:37 +00:00
Craig Topper
f543143a73 [X86] Add AVX 256-bit load and stores to fast isel.
I'm not sure why this was missing for so long.

This also exposed that we were picking floating point 256-bit VMOVNTPS for some integer types in normal isel for AVX1 even though VMOVNTDQ is available. In practice it doesn't matter due to the execution dependency fix pass, but it required extra isel patterns. Fixing that in a follow up commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271481 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 04:19:45 +00:00
Craig Topper
581e354beb [X86] Use uint16_t for a couple arrays of instruction opcodes. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271480 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-02 04:19:42 +00:00
Rafael Espindola
dddfc0bb56 Refactor X86 symbol access classification.
This refactors the logic in X86 to avoid code duplication. It also
splits it in two steps: it first decides if a symbol is local to the DSO
and then uses that information to decide how to access it.

The first part is implemented by shouldAssumeDSOLocal. It is not in any
way specific to X86. In a followup patch I intend to move it to
somewhere common and reused it in other backends.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270209 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-20 12:20:10 +00:00
Rafael Espindola
c2d48e6efd Record a TargetMachine instead of a Reloc::Model.
Addresses r270095's code review.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270147 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 22:07:57 +00:00
Rafael Espindola
187ca85319 Remember the relocation model. NFC.
This avoids passing a TargetMachine in a few places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270095 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 18:49:29 +00:00
Rafael Espindola
0323a2e3a3 Style fixes. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270093 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 18:34:20 +00:00
David Majnemer
6c67e89b60 [X86] Lower zext i1 arguments
i1 is now a legal type for X86 with AVX512.
There were some paths in X86FastISel which were not quite ready to see
an i1 value: they were not quite sure how to deal with sign/zero extends
for call arguments.
DTRT by extending to i8 for zeroext and bailing out of FastISel for
signext.

This fixes PR27591.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268470 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-04 00:22:23 +00:00
Quentin Colombet
6c76c8948d [X86][FastISel] Make sure we use the right register class when we select stores.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267806 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-27 22:33:42 +00:00
Manman Ren
a80d09e041 Swift Calling Convention: use %RAX for sret.
We don't need to copy the sret argument into %rax upon return.
rdar://25671494


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267579 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-26 18:08:06 +00:00
Asaf Badouh
ec050f449d [X86] enable PIE for functions
Call locally defined function directly for PIE/fPIE

Differential Revision: http://reviews.llvm.org/D19226

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266863 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-20 08:32:57 +00:00
Reid Kleckner
13fb5a3f1f Sink DI metadata usage out of MachineInstr.h and MachineInstrBuilder.h
MachineInstr.h and MachineInstrBuilder.h are very popular headers,
widely included across all LLVM backends. It turns out that there only a
handful of TUs that actually care about DI operands on MachineInstrs.

After this change, touching DebugInfoMetadata.h and rebuilding llc only
needs 112 actions instead of 542.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266351 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-14 18:29:59 +00:00
Manman Ren
b99afeb7f7 Swift Calling Convention: swifterror target support.
Differential Revision: http://reviews.llvm.org/D18716


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265997 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-11 21:08:06 +00:00