19817 Commits

Author SHA1 Message Date
HaohaiWen
9bde5becb4
[BranchFolding][SEH] Add test to track SEH CFG optimization (#77598)
This test tracks BranchFolding pass which removes fall through jump and
leaves landing-pad to be machine basic block of no predecessors. It
would raise bug as introduced in #77441.
2024-01-10 22:34:18 +08:00
Simon Pilgrim
cc21aa1922 [X86] lower1BitShuffle - fold permute(setcc(x,y)) -> setcc(permute(x),permute(y)) for 32/64-bit element vectors
Noticed in #77459 - for wider element types, its usually better to pre-shuffle the comparison arguments if we can, like we already for broadcasts
2024-01-10 12:35:50 +00:00
Simon Pilgrim
78cf2c041b [X86] pr77459.ll - add missing AVX512 check prefixes
Missed these in 3210ce276350a247220b193db12a9b45d1034724 for the #77459 fix
2024-01-10 12:09:38 +00:00
HaohaiWen
c9124adfd8
Revert "[SEH][CodeGen] Add test to track CFG optimization bug for SEH" (#77542)
Reverts llvm/llvm-project#77441
I'll land it with fix.
2024-01-10 09:25:45 +08:00
Zequan Wu
4e8986fc58
[Coverage] Mark coverage sections as metadata sections on COFF. (#76834)
Mark `.lcovmap$M`, `.lcovfun$M`, `.lcovd` and `.lcovn` as metadata
sections on COFF so they are not loaded into memory.
2024-01-09 16:58:28 -05:00
Simon Pilgrim
3210ce2763 [X86] Fold (iX bitreverse(bitcast(vXi1 X))) -> (iX bitcast(shuffle(X)))
X86 doesn't have a BITREVERSE instruction, so if we're working with a casted boolean vector, we're better off shuffling the vector instead if we have PSHUFB (SSSE3 or later)

Fixes #77459
2024-01-09 19:06:32 +00:00
Simon Pilgrim
417df8ee4a [X86] Add test coverage for #77459 2024-01-09 18:55:05 +00:00
Fangrui Song
f972e4d343 [MC,ELF] .section: unconditionally print section flag 'G' after 'o'
* Placing 'G' before 'M' (SHF_MERGE) can be misleading as the sh_entsize
  argument goes before the section group name, if a reader doesn't know
  that the order of extra arguments is not affected by the order of flags.
* 'a', 'w', and 'x' indicate basic permission-related flags. Separating
  them with 'G' is kinda ugly.

Simplify code and move 'G' after 'o'. The new output is more similar to
GCC.
2024-01-09 10:48:23 -08:00
Fangrui Song
7620f03ef7
[MC] Parse SHF_LINK_ORDER argument before section group name (#77407)
When both SHF_LINK_ORDER | SHF_GROUP flags are set, GNU assembler from
2.35 onwards (https://sourceware.org/PR25381
https://sourceware.org/binutils/docs/as/Section.html) parses the
SHF_LINK_ORDER argument before section group name, different from us.

This is unfortunate, but does not matter because the `.section` flag `o`
is a niche feature only used by compiler instrumentations, not adopted
by hand-written assembly, and using both flags is extremely rare. Let's
just match GNU assembler. There is another benefit: we now support
zero-flag section group with the SHF_LINK_ORDER flag, while previously
there isn't a syntax.

While here, print 'G' after 'o' to be clear that the 'G' argument is
parsed after the 'o' argument. To make the diff smaller, we don't print
'G' after 'w' in the absence of 'o' for now.
2024-01-09 10:42:34 -08:00
HaohaiWen
a2dba0c977
[SEH][CodeGen] Add test to track CFG optimization bug for SEH (#77441)
LiveDebugValues requires CFG only has one entry. BranchFolding and
MachineBlockPlacement may remove all predecessors of landing pad which
leaves it to be another entry.
2024-01-09 22:30:13 +08:00
Nick Anderson
f1ec0d12bb
Port CodeGenPrepare to new pass manager (and BasicBlockSectionsProfil… (#77182)
Port CodeGenPrepare to new pass manager and dependency
BasicBlockSectionsProfileReader
Fixes: #75380

Co-authored-by: Krishna-13-cyber <84722531+Krishna-13-cyber@users.noreply.github.com>
2024-01-09 13:32:59 +07:00
Shengchen Kan
38ce770ef1 [X86][test] Add test to check ah is not allocatable for register class gr8_norex2
This test should be added after #73529
2024-01-09 14:28:38 +08:00
Simon Pilgrim
d460c1de3b
[DAG] SimplifyDemandedBits - don't fold sext(x) -> aext(x) if we lose an 0/-1 allsignbits mask (#77296)
For targets that use 0/-1 boolean results, we want to keep this pattern through extensions/truncations as much as possible - so avoid simplifying to any_extend even if we don't demand the upper bits.

Noticed in triage for https://reviews.llvm.org/D152928
2024-01-08 18:01:41 +00:00
Simon Pilgrim
52ebf61bac [X86] ftrunc.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.

Add common AVX check prefix for 32/64 bit test coverage
2024-01-08 17:25:44 +00:00
Simon Pilgrim
fbfc9cb7ea [X86] vector-shuffle-mmx.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.

Add nounwind to remove cfi noise as well.
2024-01-08 17:25:44 +00:00
Simon Pilgrim
9632f98716 [X86] legalize-shl-vec.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.

Add nounwind to remove cfi noise as well.
2024-01-08 17:25:44 +00:00
Simon Pilgrim
635f6d3845 [X86] inline-sse.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-08 17:25:44 +00:00
Simon Pilgrim
8bd16789ff [X86] lea-2.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only (although in this case the gnux32 tests share the X64 checks)
2024-01-08 17:25:43 +00:00
Simon Pilgrim
61dcfaa745 [X86] i64-mem-copy.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.

Add nounwind to remove cfi noise as well.
2024-01-08 17:25:43 +00:00
Simon Pilgrim
f3f6677311 [X86] combine-bextr.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.

Add nounwind to remove cfi noise as well.
2024-01-08 17:25:43 +00:00
Simon Pilgrim
0e4a38018a [X86] avx2-nontemporal.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-08 12:37:34 +00:00
Simon Pilgrim
f1e3a8f1eb [X86] avx2-gather.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-08 12:37:06 +00:00
Simon Pilgrim
e3f8e44b00 [X86] vector-lzcnt-256.ll / vector-tzcnt-256.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-08 12:35:48 +00:00
Simon Pilgrim
eb523a4d27 [X86] vec_extract - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-08 12:33:47 +00:00
Shengchen Kan
1c674666fa
[X86] Support EVEX compression for EGPR (#77202)
Compress promoted instruction (EVEX) to pre-promotion instruction
(legacy/VEX) when R16-R31 is not used.

Alternative of #77065
2024-01-08 16:50:23 +08:00
Shengchen Kan
a5902a4d24 [X86][NFC] Rename variables/passes for EVEX compression optimization
RFC: https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031

APX introduces EGPR, NDD and NF instructions. In addition to compressing
EVEX encoded AVX512 instructions into VEX encoding, we also have several
more possible optimizations.

a. Promoted instruction (EVEX space) -> pre-promotion instruction (legacy space)
b. NDD (EVEX space) -> non-NDD (legacy space)
c. NF_ND (EVEX space) -> NF (EVEX space)

The first two types of compression can usually reduce code size, while
the third type of compression can help hardware decode although the
instruction length remains unchanged.

So we do the renaming for the upcoming APX optimizations.

BTW, I clang-format the code in X86CompressEVEX.cpp,
X86CompressEVEXTablesEmitter.cpp.

This patch also extracts the NFC in #77065 into a separate commit.
2024-01-06 12:41:09 +08:00
Orlando Cazalet-Hyams
10b03e6662
[RemoveDIs] Handle DPValues in FastISel (#76952)
The change is fairly mechanical:
1. Factor code from `FastISel::selectIntrinsicCall`, which converts
debug intrinsics into debug instructions, into functions (NFC).
2. Call those functions for DPValues attached to instructions too.

The test updates look the same as other RemoveDIs changes: re-run the
tests with `--try-experimental-debuginfo-iterators`, which checks the
output is identical using the new debug info format (if it has been
enabled in the cmake configuration).

Depends on #76941 (otherwise some modified tests spuriously fail).
2024-01-05 15:11:47 +00:00
Simon Pilgrim
ae81400a0f [X86] keylocker-intrinsics.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-05 13:38:44 +00:00
Simon Pilgrim
b51130a331 [X86] combine-fneg.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-05 13:38:44 +00:00
Simon Pilgrim
4ecd6384af [X86] fp128-cast.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-05 13:38:44 +00:00
Simon Pilgrim
c307147660 [X86] vec_fptrunc.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-05 13:38:43 +00:00
Simon Pilgrim
1dbdf7658a [X86] vec_fpext.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-05 13:38:43 +00:00
Simon Pilgrim
7648371c25 Revert 4d7c5ad58467502fcbc433591edff40d8a4d697d "[NewPM] Update CodeGenPreparePass reference in CodeGenPassBuilder (#77054)"
Revert e0c554ad87d18dcbfcb9b6485d0da800ae1338d1 "Port CodeGenPrepare to new pass manager (and BasicBlockSectionsProfil… (#75380)"

Revert #75380 and #77054 as they were breaking EXPENSIVE_CHECKS buildbots: https://lab.llvm.org/buildbot/#/builders/104
2024-01-05 12:28:10 +00:00
XinWang10
f5f66e26b5
[X86]Support lowering for APX Promoted SHA/MOVDIR/CRC32/INVPCID/CET instructions (#76786)
R16-R31 was added into GPRs in
https://github.com/llvm/llvm-project/pull/70958,
This patch supports the lowering for promoted
SHA/MOVDIR/CRC32/INVPCID/CET.

RFC:
https://discourse.llvm.org/t/rfc-design-for-apx-feature-egpr-and-ndd-support/73031/4
2024-01-05 15:56:15 +08:00
Phoebe Wang
59af659ee3
[X86][BF16] Try to use f16 for lowering (#76901)
This patch fixes BF16 32-bit ABI problem:
https://godbolt.org/z/6dMnh8jGG
2024-01-05 15:25:18 +08:00
Nick Anderson
e0c554ad87
Port CodeGenPrepare to new pass manager (and BasicBlockSectionsProfil… (#75380)
Port CodeGenPrepare to new pass manager and dependency
BasicBlockSectionsProfileReader
Fixes: #64560

Co-authored-by: Krishna-13-cyber <84722531+Krishna-13-cyber@users.noreply.github.com>
2024-01-05 13:47:56 +07:00
Benoit Jacob
054b5fc0fd
X86: add some missing lowerings for shuffles on bf16 element type. (#76076)
Some shuffles with `bf16` as element type were running into a
`llvm_unreachable`. Key to reproducing was to chain two shuffles.

```llvm
define <2 x bfloat> @shuffle_chained_v32bf16_v2bf16(<32 x bfloat> %a) {
  %s = shufflevector <32 x bfloat> %a, <32 x bfloat> zeroinitializer, <32 x i32> <i32 0, i32 16, i32 1, i32 17, i32 2, i32 18, i32 3, i32 19, i32 4, i32 20, i32 5, i32 21, i32 6, i32 22, i32 7, i32 23, i32 8, i32 24, i32 9, i32 25, i32 10, i32 26, i32 11, i32 27, i32 12, i32 28, i32 13, i32 29, i32 14, i32 30, i32 15, i32 31>
  %s2 = shufflevector <32 x bfloat> %s, <32 x bfloat> zeroinitializer, <2 x i32> <i32 0, i32 1>
  ret <2 x bfloat> %s2
}
```

This was hitting this UNREACHABLE:

```
Not a valid 512-bit x86 vector type!
UNREACHABLE executed at /home/benoit/iree/third_party/llvm-project/llvm/lib/Target/X86/X86ISelLowering.cpp:17124!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/benoit/mlir-build/bin/llc -mtriple=x86_64-unknown-linux-gnu -mattr=+avx512f,+avx512vl,+avx512bw,+avx512bf16
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@shuffle_chained_v32bf16_v2bf16'
```
2024-01-04 22:39:40 -05:00
Simon Pilgrim
2cbf652615 [X86] avx512-pmovxrm.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-04 17:17:08 +00:00
Simon Pilgrim
63e3074781 [X86] aligned-variadic.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-04 17:17:07 +00:00
Simon Pilgrim
ce4459d590 [X86] 64-bit-shift-by-32-minus-y.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-04 17:17:07 +00:00
Simon Pilgrim
076dbc0272 [X86] SimplifyDemandedVectorEltsForTargetNode - add X86ISD::VZEXT_LOAD handling.
Simplify to a scalar_to_vector(load()) if we don't demand any of the upper vector elements.
2024-01-04 17:17:07 +00:00
Simon Pilgrim
5cd3cf1072 [X86] cvtv2f32.ll - replace X32 checks with X86. NFC.
We try to use X32 for gnux32 triples only.
2024-01-04 17:17:06 +00:00
HaohaiWen
e147dcbcbc
[SEH] Add test to track EHa register liveness verification (#76921)
This test tracks bug of MachineVerifier to check live range segment for
EHa. Async exception can happen at any place within seh scope, not only
the call instruction. Need to teach MachineVerifier to know that.
2024-01-04 20:49:11 +08:00
Phoebe Wang
176c341198 [X86][BF16] Add 32-bit tests to show ABI problem, NFC 2024-01-04 15:43:34 +08:00
Micah Weston
7df28fd61a
[SHT_LLVM_BB_ADDR_MAP][AsmPrinter] Implements PGOAnalysisMap emitting in AsmPrinter with tests. (#75202)
Uses machine analyses to emit PGOAnalysisMap into the bb-addr-map ELF
section. Implements filecheck tests to verify emitting new fields.

This patch emits optional PGO related analyses into the bb-addr-map ELF
section during AsmPrinter. This currently supports Function Entry Count,
Machine Block Frequencies. and Machine Branch Probabilities. Each is
independently enabled via the `feature` byte of `bb-addr-map` for the given
function.

A part of [RFC - PGO Accuracy Metrics: Emitting and Evaluating Branch and Block Analysis](https://discourse.llvm.org/t/rfc-pgo-accuracy-metrics-emitting-and-evaluating-branch-and-block-analysis/73902).
2024-01-03 19:17:44 -05:00
Craig Topper
47a1704ac9
[SelectionDAG][X86] Use disjoint flag in SelectionDAG::isADDLike. (#76847)
Keep the haveNoCommonBitsSet check because we haven't started inferring
the flag yet.

I've added tests for two transforms, but these are not the only
transforms that use isADDLike.
2024-01-03 11:54:29 -08:00
Arthur Eubanks
c4146121e9 Revert "Reapply "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG""
This reverts commit 0e46b49de43349f8cbb2a7d4c6badef6d16e31ae.

Causes crashes, see repro on 0e46b49de4.
2024-01-03 17:09:46 +00:00
Simon Pilgrim
1d27669e8a [X86] combineConcatVectorOps - fold 512-bit concat(blendi(x,y,c0),blendi(z,w,c1)) to AVX512BW mask select
Yet another yak shaving regression fix for #73509
2024-01-03 12:38:26 +00:00
Simon Pilgrim
39be138cb7 [X86] combineTargetShuffle - fold SHUF128(CONCAT(),CONCAT()) to peek through upper subvectors
If SHUF128 is accessing only the upper half of a vector source that is a concatenation/insert_subvector then try to access the subvector directly and adjust the element mask accordingly.
2024-01-03 11:09:14 +00:00
Simon Pilgrim
58a335a3f1 [X86] Fold concat_vectors(permq(x),permq(x)) -> permq(concat_vectors(x,x))
Handle a common subvector shuffle pattern in combineConcatVectorOps
2024-01-03 11:09:14 +00:00