19133 Commits

Author SHA1 Message Date
Vy Nguyen
e60b30d5e3 Reland "D144999 [MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs."
Reasons for rolling forward:
    - the crash reported from Chromium was fixed in D151824 (not related to this patch at all)
    - since D152824 was committed, it should now be safe to roll this forward.

New change:
    - add an additional _ in name check

This reverts commit 4980eead4d0b4666d53dad07afb091375b3a13a0.
2023-06-07 10:03:50 -04:00
Phoebe Wang
2011ad0cbb [X86][FP16] Do not generate VBROADCAST for fp16
We cannot lower VBROADCAST i16 under AVX1.

Fixes #63114

Differential Revision: https://reviews.llvm.org/D152350
2023-06-07 20:54:56 +08:00
Simon Pilgrim
49bd51d918 [X86] Add test case for Issue #63108 2023-06-07 10:19:14 +01:00
Matt Arsenault
eece6ba283 IR: Add llvm.ldexp and llvm.experimental.constrained.ldexp intrinsics
AMDGPU has native instructions and target intrinsics for this, but
these really should be subject to legalization and generic
optimizations. This will enable legalization of f16->f32 on targets
without f16 support.

Implement a somewhat horrible inline expansion for targets without
libcall support. This could be better if we could introduce control
flow (GlobalISel version not yet implemented). Support for strictfp
legalization is less complete but works for the simple cases.
2023-06-06 17:07:18 -04:00
Simon Pilgrim
a279a09ab9 Revert rG98061013e01207444cfd3980 - [X86] X86FixupVectorConstantsPass - attempt to replace full width fp vector constant loads with broadcasts on AVX+ targets
Reverting while we address an existing issue exposed by this (Issue #63108)
2023-06-06 18:44:24 +01:00
Simon Pilgrim
78de45fd4a Revert rGab4b924832ce26c21b88d7f82fcf4992ea8906bb - [X86] X86FixupVectorConstantsPass - attempt to replace full width integer vector constant loads with broadcasts on AVX2+ targets
Reverting while we address an existing issue exposed by this (Issue #63108)
2023-06-06 18:07:33 +01:00
Simon Pilgrim
85b77b13e3 [GlobalISel][X86] Add G_IMPLICIT_DEF / G_CONSTANT legalization handling 2023-06-06 11:45:22 +01:00
Thorsten Schütt
60b8019ea0 [GlobalIsel][X86] Legalize G_ANYEXT, G_SEXT, and G_ZEXT
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D152243
2023-06-06 12:22:09 +02:00
Serge Pavlov
10e7899818 [FPEnv] Get rid of extra moves in fpenv calls
If intrinsic `get_fpenv` or `set_fpenv` is lowered to the form where FP
environment is represented as a region in memory, extra moves can
appear. For example the code:

  define void @func_01(ptr %ptr) {
    %env = call i256 @llvm.get.fpenv.i256()
    store i256 %env, ptr %ptr
    ret void
  }

produces DAG:

  ch = get_fpenv_mem ch, memory_region
  val: i256, ch = load ch, memory_region
  ch = store ch, ptr, val

In this case the extra moves can be avoided if `get_fpenv_mem` got
pointer to the memory where the FP environment should be finally placed.

This change implement such optimization for this use case.

Differential Revision: https://reviews.llvm.org/D150437
2023-06-06 14:54:52 +07:00
Luo, Yuanke
787f3008be [X86] Pre-commit test case for D152227. 2023-06-06 14:56:45 +08:00
Luo, Yuanke
60b7dbb670 [X86] Add test cases for D152227. 2023-06-06 14:24:46 +08:00
JP Lehr
c9998ec145 Revert "[DAGCombine] Make sure combined nodes are added back to the worklist in topological order."
This reverts commit e69fa03ddd85812be3143d79a0359c3e8d43bd45.

This patch lead to build time outs on the AMDGPU OpenMP runtime
buildbot.
2023-06-05 10:55:58 -04:00
Simon Pilgrim
c2926c6c4d [GlobalISel][X86] Regenerate legalize-undef.mir 2023-06-05 14:41:40 +01:00
Simon Pilgrim
ca0caa23ce [X86] Replace X32 test check prefix with X86 + add common CHECK prefix
We try to only use X32 for gnux32 triple test cases
2023-06-05 14:41:40 +01:00
Simon Pilgrim
fcacc41a22 [X86] Replace X32 test check prefix with X86
We try to only use X32 for gnux32 triple test cases
2023-06-05 14:41:40 +01:00
Amaury Séchet
e69fa03ddd [DAGCombine] Make sure combined nodes are added back to the worklist in topological order.
Currently, a node and its users are added back to the worklist in reverse topological order after it is combined. This diff changes that order to be topological. This is part of a larger migration to get the DAGCombiner to process nodes in topological order.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D127115
2023-06-05 11:09:18 +00:00
Simon Pilgrim
b28bc5f5ad [GlobalISel][X86] Add 128/256/512-bit vector and/or/xor test coverage
Based off the legalize-add-v*.mir tests
2023-06-05 12:08:22 +01:00
Simon Pilgrim
dbd3695092 [GlobalISel][X86] Add illegal types and 32-bit target scalar and/or/xor test coverage
Based off the legalize-add.mir tests
2023-06-05 12:08:22 +01:00
Simon Pilgrim
d37bd544ff [X86] canonicalizeShuffleWithBinOps - ensure a binary shuffle of binops have the same value type
Fixes #63091
2023-06-05 11:18:28 +01:00
Simon Pilgrim
d75efc1d51 [X86] Add test case for Issue #63091 2023-06-05 11:18:27 +01:00
Simon Pilgrim
346ee549e5 [GlobalISel][X86] Add G_CTTZ_ZERO_UNDEF/G_CTTZ legalization handling
G_CTTZ_ZERO_UNDEF is always legal using the BSF instruction, G_CTTZ requires the BMI1 TZCNT instruction
2023-06-05 11:18:27 +01:00
Serge Pavlov
eecaeb6f10 [FPEnv] Intrinsics for access to FP environment
The change implements intrinsics 'get_fpenv', 'set_fpenv' and 'reset_fpenv'.
They are used to read floating-point environment, set it or reset to
some default state. They do the same actions as C library functions
'fegetenv' and 'fesetenv'. By default these intrinsics are lowered to calls
to these functions.

The new intrinsics specify FP environment as a value of integer type, it
is convenient of most targets where the FP state is a content of some
register. Some targets however use long representations. On X86 the size
of FP environment is 256 bits, and even half of this size is not a legal
ibteger type. To facilitate legalization in such cases, two sets of DAG
nodes is used. Nodes GET_FPENV and SET_FPENV are used when FP
environment may be represented by a legal integer type. Nodes
GET_FPENV_MEM and SET_FPENV_MEM consider FP environment as a region in
memory, much like `fesetenv` and `fegetenv` do. They are used when
target has long representation for floationg-point state.

Differential Revision: https://reviews.llvm.org/D71742
2023-06-05 13:10:01 +07:00
Simon Pilgrim
9424a54201 [GlobalIsel][X86] Update legalization of G_AND/G_OR/G_XOR
Replace the legacy G_AND/G_OR/G_XOR legalizer, this handles all scalar promotion and vector clamping (allows AVX1 to handle 256-bit logic ops).
2023-06-04 11:44:27 +01:00
Simon Pilgrim
4dcd66a005 [GlobalIsel][X86] Update legalization of G_MUL
Replace the legacy G_MUL legalizer, this handles all scalar promotion and vector clamping, however we still need to add custom legalization for many vector multiplies.
2023-06-03 18:22:02 +01:00
Simon Pilgrim
41f8b6fe74 [GlobalIsel][X86] Regenerate G_MUL scalar legalization tests
Add i8 test coverage
2023-06-03 11:18:51 +01:00
Simon Pilgrim
4fcbe5fbed Revert rG2f9a4d308d4517eee85e373bc09920f85f91fdcd "[GlobalISel][X86] Add G_CTLZ_ZERO_UNDEF legalization handling"
Unintentional commit - G_CTLZ_ZERO_UNDEF will have to be custom handled as BSR needs the bits flipping (and we don't have a pattern for that yet).
2023-06-02 18:43:11 +01:00
Simon Pilgrim
2f9a4d308d [GlobalISel][X86] Add G_CTLZ_ZERO_UNDEF legalization handling 2023-06-02 18:25:03 +01:00
Simon Pilgrim
4c5355db81 [GlobalIsel][X86] Merge LZCNT 32-bit and 64-bit test coverage 2023-06-02 16:26:35 +01:00
Simon Pilgrim
ec24d36faa [GlobalIsel][X86] Add G_ADD/G_SUB i8/i16 and promotion legalization tests
Add i8/i16/i24/i42 ADD/SUB test coverage
2023-06-02 14:41:30 +01:00
Simon Pilgrim
db3d6aca14 [GlobalIsel][X86] Regenerate G_ADD/G_SUB vector legalization tests 2023-06-02 14:41:30 +01:00
Thorsten Schütt
3ac9aa2020 [GlobalIsel][X86] Legalize G_BSWAP III
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D151915
2023-06-02 11:42:25 +02:00
Haohai Wen
8db674ad06 [X86] Add schedule module for SapphireRapids
The X86SchedSapphireRapids.td file is automatically generated by
schedtool (D130897). Most of instruction's scheduling information
is from SapphireRapids tpt/lat data provided by intel doc. Some data
is from measured ADL-P data in uops.info. The rest instruction's
scheduling information is from skylake server schedule model in order
to get a relative complete model.

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D141485
2023-06-02 15:23:50 +08:00
Dávid Bolvanský
09515f2c20 [SDAG] Preserve unpredictable metadata, teach X86CmovConversion to respect this metadata
Sometimes an developer would like to have more control over cmov vs branch. We have unpredictable metadata in LLVM IR, but currently it is ignored by X86 backend. Propagate this metadata and avoid cmov->branch conversion in X86CmovConversion for cmov with this metadata.

Example:

```
int MaxIndex(int n, int *a) {
    int t = 0;
    for (int i = 1; i < n; i++) {
        // cmov is converted to branch by X86CmovConversion
        if (a[i] > a[t]) t = i;
    }
    return t;
}

int MaxIndex2(int n, int *a) {
    int t = 0;
    for (int i = 1; i < n; i++) {
        // cmov is preserved
        if (__builtin_unpredictable(a[i] > a[t])) t = i;
    }
    return t;
}
```

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D118118
2023-06-01 20:56:44 +02:00
Nikita Popov
e506bfa7ae [SDAG] Fix incorrect use of undef for boolean contents (PR63055)
FoldSetCC() returns UNDEF in a number of cases. However, the SetCC
result must follow BooleanContents. Unless the type is a
pre-legalization i1 or we have UndefinedBooleanContents, the use of
UNDEF will not uphold the requirement that the top bits are either
zero or match the low bit. In such cases, return zero instead.

Fixes https://github.com/llvm/llvm-project/issues/63055.

Differential Revision: https://reviews.llvm.org/D151883
2023-06-01 15:19:22 +02:00
Nikita Popov
9694e0fcba [X86] Add test for PR63055 (NFC) 2023-06-01 14:32:24 +02:00
Antonio Abbatangelo
b7e110fcfe [X86] Align stack to 16-bytes on 32-bit with X86_INTR call convention
Adds a dynamic stack alignment to functions under the interrupt call
convention on x86-32. This fixes the issue where the stack can be
misaligned on entry, since x86-32 makes no guarantees about the stack
pointer position when the interrupt service routine is called.

The alignment is done by overriding X86RegisterInfo::shouldRealignStack,
and by setting the correct alignment in X86FrameLowering::calculateMaxStackAlign.
This forces the interrupt handler to be dynamically aligned, generating
the appropriate `and` instruction in the prologue and `lea` in the
epilogue. The `no-realign-stack` attribute can be used as an opt-out.

Fixes #26851

Reviewed By: pengfei

Differential Revision: https://reviews.llvm.org/D151400
2023-06-01 17:00:34 +08:00
Phoebe Wang
801dd8870f [X86][BF16] Fix 2 crashes with vector broadcast
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D151808
2023-06-01 13:38:47 +08:00
Arthur Eubanks
161544dced [test] Add zero size global test to code-model-elf.ll 2023-05-31 13:04:15 -07:00
Arthur Eubanks
43249378da [X86] Use "l" prefix for data sections under medium/large code model
And also set the SHF_X86_64_LARGE section flag.

gcc only uses the "l" prefix and SHF_X86_64_LARGE in the medium code model for data larger than -mlarge-data-threshold. But it seems more consistent to use it in the large code model as well in case separate parts of the binary aren't compiled with the large code model and also have a .data/.bss/.rodata section.

Reviewed By: MaskRay, tkoeppe

Differential Revision: https://reviews.llvm.org/D148836
2023-05-31 12:31:08 -07:00
Simon Pilgrim
d6a36619ce [X86] X86FixupVectorConstantsPass - use VBROADCASTSS/VBROADCASTSD for integer vector loads on AVX1-only targets
Matches behaviour in lowerBuildVectorAsBroadcast
2023-05-31 16:39:09 +01:00
Thorsten Schütt
dd2fea9c23 [GlobalIsel][X86] Legalize G_CTLZ and G_CTPOP for 32-bit
Note that 32-bit support is very limited

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D151459
2023-05-31 14:24:52 +02:00
Simon Pilgrim
7030c01c92 [X86] Replace X32 test check prefix with X86
We try to only use X32 for gnux32 triple test cases
2023-05-31 13:01:51 +01:00
Simon Pilgrim
6432658825 [X86] Replace X32 test check prefixes with X86
We try to only use X32 for gnux32 triple test cases
2023-05-31 13:01:50 +01:00
Simon Pilgrim
f1a42300aa [X86] printConstant - fix asm comment issue when broadcasting from a wider constant pool entry
In cases where a broadcast op is loading from a constant entry wider than the broadcast element, we were incorrectly printing the entire entry and not just the lower bits referenced by the broadcast.
2023-05-31 12:28:17 +01:00
Simon Pilgrim
65dce67f16 [X86] getTargetConstantBitsFromNode - ensure we truncate broadcasts from wider constants.
We might be broadcasting the lower portion of a wider constant pool entry, ensure we truncate the full width of the constant back to the broadcast width.

(This also exposes an issue with how asm comments print these constants - I'll address that in a followup).

Fixes #63030
2023-05-31 12:08:02 +01:00
Simon Pilgrim
b85f42a4a6 [X86] Replace X32 test check prefixes with X86
We try to only use X32 for gnux32 triple test cases
2023-05-31 12:08:02 +01:00
Simon Pilgrim
0ec79f413e [X86] Regenerate sqrt-fastmath-mir.ll 2023-05-30 17:21:53 +01:00
Simon Pilgrim
ab4b924832 [X86] X86FixupVectorConstantsPass - attempt to replace full width integer vector constant loads with broadcasts on AVX2+ targets
lowerBuildVectorAsBroadcast will not broadcast splat constants in all cases, resulting in a lot of situations where a full width vector load that has failed to fold but is loading splat constant values could use a broadcast load instruction just as cheaply, and save constant pool space.
2023-05-30 13:17:26 +01:00
Simon Pilgrim
95661b9c75 [X86] getTargetConstantBitsFromNode - support extracting fp data from ConstantDataSequential
Fixes issue introduced by 0f8e0f4228805cbecce13dcfadef4c48a4f0f4cd where SimplifyDemandedBits could crash when trying to extract fp data from broadcasted constants
2023-05-30 11:38:31 +01:00
Simon Pilgrim
98061013e0 [X86] X86FixupVectorConstantsPass - attempt to replace full width fp vector constant loads with broadcasts on AVX+ targets
lowerBuildVectorAsBroadcast will not broadcast splat constants in all cases, resulting in a lot of situations where a full width vector load that has failed to fold but is loading splat constant values could use a broadcast load instruction just as cheaply, and save constant pool space.

NOTE: SSE3 targets can use MOVDDUP but not all SSE era CPUs can perform this as cheaply as a vector load, we will need to add scheduler model checks if we want to pursue this.
2023-05-29 16:10:52 +01:00