20098 Commits

Author SHA1 Message Date
Simon Pilgrim
00a6817108 [X86] v4f32-immediate.ll - replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-31 11:04:19 +00:00
Simon Pilgrim
8d450b47ba [X86] mmx-arith.ll - replace X32 check prefixes with X86 + strip cfi noise
We try to only use X32 for gnux32 triple tests.
2024-01-31 11:04:19 +00:00
Simon Pilgrim
53b9d479d5 [X86] i256-add - replace i386 triple X32 check prefixes with X86 and add gnux32 triple tests 2024-01-31 11:04:19 +00:00
Shengchen Kan
8e77390c06
[X86][CodeGen] Support folding memory broadcast in X86InstrInfo::foldMemoryOperandImpl (#79761) 2024-01-31 12:51:03 +08:00
Shengchen Kan
e5054fb5c6 [X86][test] Update CodeGen/X86/popcnt.ll after #78545 2024-01-30 18:38:16 +08:00
XinWang10
1a219e989f
[X86] Support EVEX compression from MOVBErr to BSWAP (#79775)
APX promoted MOVBE instructions were supported in #77431. The reg2reg
variants of MOVBE are newly introduced by APX and can be optimized to
BSWAP instruction when the 2 register operands are same.

This patch adds manual entries for MOVBErr instructions when we do ndd
to non-ndd compression #77731.
RFC:
https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2024-01-30 16:57:51 +08:00
XinWang10
5910e34a2f
[X86][MC] Support encoding optimization & assembler relaxation about immediate operands for APX instructions (#78545)
Encoding optimization:
```
mi/mi32 -> mi8
ri/ri32 -> ri8
```
if the immediate operand is 8-bit wide.

Assembler relaxation:
```
mi8 -> mi/mi32
ri8 -> ri/ri32
```
If the immediate operand is a symbol expression and it's value is
unknown.
2024-01-30 14:21:06 +08:00
Arthur Eubanks
198652a0ff
[X86] Treat __start_*/__stop_* symbols as large (#79909)
Followup to #79884.

The linker adds __start_foo/__stop_foo symbols pointing to the
beginning/end of the foo section. These can be far away from text, so
treat them as large symbols under the medium/large code models.
Performance to access these is almost certainly not important.
2024-01-29 21:00:16 -07:00
Arthur Eubanks
d6e07e0845
[X86] Treat __ehdr_start as large (#79884)
The __ehdr_start symbol is added by the linker and points to the ELF
file headers, which can be very far away from text. Treat it as a large
symbol under the medium/large code models. Performance to access
__ehdr_start is almost certainly not important.

There are a couple of other symbols that the linker adds [1], but this
is the most relevant one that may be far away from text.

[1]
547c395b27/lld/ELF/Writer.cpp (L226)
2024-01-29 14:25:40 -08:00
Simon Pilgrim
3ab5dbb199 [X86] sext-i1.ll - replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-29 18:00:36 +00:00
Simon Pilgrim
2aef33230d [X86] fast-isel-store.ll - cleanup check prefixes
32/64-bit triples and check prefixes were inverted, and missing unwind attribute to strip cfi noise
2024-01-29 18:00:35 +00:00
Simon Pilgrim
cbe5985ff7 [X86] Replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-29 16:50:32 +00:00
Simon Pilgrim
06f5b956a0 [X86] pmovsx-inreg.ll - replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-29 14:23:08 +00:00
Simon Pilgrim
ccb2810ee3 [X86] anyext.ll - replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-29 14:23:08 +00:00
Simon Pilgrim
8a074c84ff [X86] fixup-bw-copy.ll - replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-29 14:23:08 +00:00
Simon Pilgrim
bc879a9019 [X86] mul-i256.ll - simplify function attributes and remove cfi noise 2024-01-29 13:19:47 +00:00
Simon Pilgrim
3a4a7dcd62 [X86] Replace X32 check prefixes with X86
We try to only use X32 for gnux32 triple tests.
2024-01-29 13:19:47 +00:00
Shengchen Kan
6d7c8a6e06 [X86][test] Update failed tests in 60dbb2cec1bbf65aacf6752a59b0666a23aaa3ae after rebase 2024-01-29 00:32:30 +08:00
Shengchen Kan
60dbb2cec1 [X86][test] Update CHECK prefixes in CodeGen/X86/vector-interleaved-store-*.ll to suppress warnings
Suppress warnings like

WARNING: Prefix AVX had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX1 had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX2 had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX2-ONLY had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX512 had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX512F had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX512F-ONLY had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX512-FAST had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
WARNING: Prefix AVX512DQ-ONLY had conflicting output from different RUN lines for all functions in test vector-interleaved-store-i16-stride-7.ll
2024-01-29 00:11:17 +08:00
Shengchen Kan
5abbb7b5d0 [X86][test] Update CHECK prefixes in CodeGen/X86/vector-interleaved-load-*.ll to suppress warnings
Suppress warnings like

WARNING: Prefix AVX had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX1 had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX2 had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX2-ONLY had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX512 had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX512F had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX512F-ONLY had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX512-FAST had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
WARNING: Prefix AVX512DQ-ONLY had conflicting output from different RUN lines for all functions in test vector-interleaved-load-i16-stride-7.ll
2024-01-28 14:41:59 +08:00
Evgenii Kudriashov
cfd91199ca
[X86] Skip unused VRegs traverse (#78229)
Almost all loops with getNumVirtRegs skip unused registers by means
of reg_nodbg_empty or empty live interval. Except for these two cases
that are revealed by GlobalISel since it can skip RegClass assignment
for unused registers.

Closes #64452, closes #71926
2024-01-26 23:57:14 +01:00
Adhemerval Zanella
a58c62fa82
[X86] Do not end 'note.gnu.property' section with -fcf-protection (#79360)
The glibc now adds the required minimum ISA level for libc-nonshared.a
(linked on all programs) and this is done with an inline asm along with
.note.gnu.property and .pushsection/.popsection. However, the x86
backend always ends the 'note.gnu.property' section when building with
-fcf-protection, leading to assert failure:

llvm/llvm-project-git/llvm/lib/MC/MCStreamer.cpp:1251: virtual void
llvm::MCStreamer::switchSection(llvm::MCSection*, const llvm::MCExpr*):
Assertion `!Section->hasEnded() && "Section already ended"' failed.

[1]
https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/x86/isa-level.c;h=3f1b269848a52f994275bab6f60dded3ded6b144;hb=HEAD
2024-01-26 10:33:47 -08:00
Evgenii Kudriashov
a437347562
[X86][GlobalISel] Remove G_OR/G_AND/G_XOR test duplication (NFC) (#79088) 2024-01-26 16:48:51 +01:00
Simon Pilgrim
1f930cf894 [X86] Fold not(pcmpeq(and(X,CstPow2),0)) -> pcmpeq(and(X,CstPow2),CstPow2) (REAPPLIED)
Reapply b9483d30a7d7a0650a0e83c75fcb9ab4932f475a with fix (typo - wasn't ensuring icmp vs zero)

Fixes #78888
2024-01-26 15:13:59 +00:00
Shengchen Kan
d9245e8b47 [X86][ISEL] Add NDD entries in X86ISelDAGToDAG.cpp 2024-01-26 23:02:53 +08:00
Shengchen Kan
035f33bf41 [X86][CodeGen] Add NDD entries for X86InstrInfo::foldImmediate 2024-01-26 22:11:57 +08:00
Shengchen Kan
821dee9852 [X86][CodeGen] Add NDD entries for isAssociativeAndCommutative 2024-01-26 18:39:52 +08:00
Shengchen Kan
14a027b2b7
[X86][CodeGen] Support flags copy lowering for NDD ADC/SBB/RCL/RCR (#79280) 2024-01-26 16:49:44 +08:00
XinWang10
02d56801ee
[X86] Support APX promoted RAO-INT and MOVBE instructions (#77431)
R16-R31 was added into GPRs in
https://github.com/llvm/llvm-project/pull/70958,
This patch supports the promoted RAO-INT and MOVBE instructions in EVEX
space.

RFC:
https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2024-01-26 14:33:45 +08:00
XinWang10
6d0080b5de
[X86] Support promoted ENQCMD, KEYLOCKER and USERMSR (#77293)
R16-R31 was added into GPRs in
https://github.com/llvm/llvm-project/pull/70958,
This patch supports the promoted ENQCMD, KEYLOCKER and USER-MSR
instructions in EVEX space.

RFC:
https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2024-01-26 14:24:43 +08:00
Douglas Yung
b9483d30a7 Revert "[X86] Fold not(pcmpeq(and(X,CstPow2),0)) -> pcmpeq(and(X,CstPow2),CstPow2)"
This reverts commit 72f10f7eb536da58cb79e13974895cd97d4e1a5f.

This change was causing a miscompile on an internal test and is being reverted at the author's request until it can be fixed.
2024-01-25 09:40:16 -08:00
Felipe de Azevedo Piovezan
380ac53dfa
[DebugNames] Implement Entry::GetParentEntry query (#78760)
This commit introduces a helper function to DWARFAcceleratorTable::Entry
which follows DW_IDX_Parent attributes to returns the corresponding
parent Entry in the table.

It is tested by enhancing dwarfdump so that it now prints:

1. When data is corrupt.
2. When parent information is present, but the parent is not indexed.
3. The parent entry offset, when the parent is present and indexed. This
is printed in terms a real entry offset (the same that gets printed at
the start of each entry: "Entry @ 0x..."), instead of the encoded number
in the table (which is an offset from the start off the Entry list).
This makes it easy to visually inspect the dwarfdump and check what the
parent is.
2024-01-24 06:44:03 -08:00
Simon Pilgrim
8b43c1be23
[X86] X86FixupVectorConstants - shrink vector load to movsd/movsd/movd/movq 'zero upper' instructions (#79000)
If we're loading a vector constant that is known to be zero in the upper elements, then attempt to shrink the constant and just scalar load the lower 32/64 bits.

Always chose the vzload/broadcast with the smallest constant load, and prefer vzload over broadcasts for same bitwidth to avoid domain flips (mainly a AVX1 issue).

Fixes #73783
2024-01-24 14:00:51 +00:00
Simon Pilgrim
72f10f7eb5 [X86] Fold not(pcmpeq(and(X,CstPow2),0)) -> pcmpeq(and(X,CstPow2),CstPow2)
Fixes #78888
2024-01-24 12:04:45 +00:00
Simon Pilgrim
6255bae6c9 [X86] Add test coverage based on #78888 2024-01-24 12:04:44 +00:00
Shengchen Kan
33ecef9812
[X86][CodeGen] Fix crash when commute operands of Instruction for code size (#79245)
Reported in 134fcc62786d31ab73439201dce2d73808d1785a

Incorrect opcode is used  b/c there is a `[[fallthrough]]` at line 2386.
2024-01-24 17:10:28 +08:00
Shengchen Kan
71d64ed80f [X86][Peephole] Add NDD entries for EFLAGS optimization 2024-01-24 15:47:58 +08:00
Shengchen Kan
d119ecb958 [X86][NFC] Pre-commit test for RA hints for APX NDD instructions 2024-01-24 14:44:34 +08:00
Shengchen Kan
f7b61f81b5
[X86][CodeGen] Transform NDD SUB to CMP if dest reg is dead (#79135) 2024-01-24 13:58:48 +08:00
Paul Kirth
9d476e1e1a
[clang][FatLTO] Avoid UnifiedLTO until it can support WPD/CFI (#79061)
Currently, the UnifiedLTO pipeline seems to have trouble with several
LTO features, like SplitLTO units, which means we cannot use important
optimizations like Whole Program Devirtualization or security hardening
instrumentation like CFI.

This patch reverts FatLTO to using distinct pipelines for Full LTO and
ThinLTO. It still avoids module cloning, since that was error prone.
2024-01-23 14:04:52 -08:00
Simon Pilgrim
e1aa5b1fd1 [DAG] visitSCALAR_TO_VECTOR - don't fold scalar_to_vector(bin(extract(x),extract(y)) -> bin(x,y) if extracts have other uses
Fixes #78897 - although the test case still has a number of poor codegen issues (in particular for i686 triples) that will need addressing (combining the nodes in topological order should help).
2024-01-23 16:28:43 +00:00
Simon Pilgrim
8c41e3fcb1 [X86] Add test case for Issue #78897 2024-01-23 15:44:01 +00:00
Jeremy Morse
087172258a [DebugInfo][RemoveDIs] Handle non-instr debug-info in GlobalISel (#75228)
The RemoveDIs project is aiming to eliminate debug intrinsics like
dbg.value and dbg.declare from LLVM, and replace them with DPValue objects
attached to instructions. ISel is one of the "terminals" where that
information needs to be converted into MIR format: this patch implements
support for that in GlobalISel. We aim for the output of LLVM to be
identical with/without RemoveDIs debug-info.

This patch should be NFC, as we're handling the same data about variables
stored in a different format -- it now appears in a DPValue object rather
than as an intrinsic. To that end, I've refactored the handling of
dbg.values into a dedicated function, and call it whenever a dbg.value or a
DPValue is encountered. dbg.declare is handled in a similar way.

Testing: adding the --try-experimental-debuginfo-iterators switch to llc
causes it to try and convert to the "new" debug-info format if it's built
in (LLVM_EXPERIMENTAL_DEBUGINFO_ITERATORS=On), and it'll be covered by our
buildbot. One test has a few extra wildcard-regexes added: this is because
there's some extra data printed about attached debug-info, which is safe to
ignore.
2024-01-23 15:04:08 +00:00
Simon Pilgrim
4318b033bd
[MC][X86] Merge lane/element broadcast comment printers. (#79020)
This is /almost/ NFC - the only annoyance is that for some reason we were using "<C1,C2,..>" for ConstantVector types unlike all other cases - these now use the same "[C1,C2,..]" format as the other constant printers.
2024-01-23 12:33:52 +00:00
Simon Pilgrim
5c7bbe383b [X86] canonicalizeShuffleWithOp - recognise constant vectors with getTargetConstantFromNode
Allows shuffle to fold constant vectors that have already been lowered to constant pool - shuffle combining can then constant fold this.

Noticed while triaging #79100
2024-01-23 11:30:06 +00:00
Shengchen Kan
66237d647e [X86][CodeGen] Add entries for NDD SHLD/SHRD to the commuteInstructionImpl 2024-01-23 17:05:09 +08:00
Shengchen Kan
5c68c6d70f
[X86] Support encoding/decoding and lowering for APX variant SHL/SHR/SAR/ROL/ROR/RCL/RCR/SHLD/SHRD (#78853)
Four variants: promoted legacy, ND (new data destination), NF (no flags
update) and NF_ND (NF + ND).

The syntax of NF instructions is aligned with GNU binutils.
https://sourceware.org/pipermail/binutils/2023-September/129545.html
2024-01-23 10:23:27 +08:00
Alexandre Ganea
bb28442c0b
[CodeGen][X86] Fix lowering of tailcalls when -ms-hotpatch is used (#77245)
Previously, tail jump pseudo-opcodes were skipped by the
`encodeInstruction()` call inside `X86AsmPrinter::LowerPATCHABLE_OP`.
This caused emission of a 2-byte NOP and dropping of the tail jump.

With this PR, we change `PATCHABLE_OP` to not wrap the first
`MachineInstr` anymore, but inserting itself before,
leaving the instruction unaltered. At lowering time in `X86AsmPrinter`,
we now "look ahead" for the next non-pseudo `MachineInstr` and
lower+encode it, to inspect its size. If the size is below what
`PATCHABLE_OP` expects, it inserts NOPs; otherwise it does nothing. That
way, now the first `MachineInstr` is always lowered as usual even if
`"patchable-function"="prologue-short-redirect"` is used.

Fixes https://github.com/llvm/llvm-project/issues/76879,
https://github.com/llvm/llvm-project/issues/76958 and
https://github.com/llvm/llvm-project/issues/59039
2024-01-22 14:19:08 -05:00
Jeremy Morse
d7fb9eb818
[DebugInfo][RemoveDIs] Handle DPValues in SelectOptimize (#79005)
When there are debug intrinsics in-between groups of select
instructions, select-optimise sinks them into the "end" block. This
needs to be replicated for DPValues, the non-instruction variable
assignment object. Implement that and add a RUN line to a test that was
sensitive to this to ensure it gets tested.

(The exact range of instructions being transformed here is a little
fiddly, hence I've gone with a helper lambda).
2024-01-22 18:12:24 +00:00
Simon Pilgrim
27eb8d53ae [X86] printConstant - add ConstantVector handling 2024-01-22 15:59:55 +00:00