48580 Commits

Author SHA1 Message Date
Simon Pilgrim
ff23856c1c [DAG] Fold (abds x, y) -> (abdu x, y) iff both args are known positive
This is a generic DAG combine version of D151055 which recognizes when a signed ABDS can be safely replaced with a unsigned ABDU instruction if it is legal.

Alive2: https://alive2.llvm.org/ce/z/pb5BjG

Differential Revision: https://reviews.llvm.org/D153328
2023-06-20 15:31:22 +01:00
Jingu Kang
cce08185b4 [AArch64] Try to fold uaddlv and uaddlp
Add tablegen pattern for uaddlv(uaddlp(x)) ==> uaddlv(x).

Differential Revision: https://reviews.llvm.org/D153323
2023-06-20 15:14:27 +01:00
Weining Lu
3dd319ecf3 [LoongArch] Optimize conditional selection of integer
This patch optimizes code generation by leveraging the zeroing behavior of the `maskeqz`/`masknez` instructions.

```
int sel(int a, int b)
{
    return (a < b) ? a : 0;
}
```

```
slt	$a1,$a0,$a1
masknez	$a2,$r0,$a1
maskeqz	$a0,$a0,$a1
or	$a0,$a0,$a2
```

=>

```
slt	$a1,$a0,$a1
maskeqz	$a0,$a0,$a1
```

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D153193
2023-06-20 21:54:40 +08:00
Pravin Jagtap
699addeff0 [AMDGPU] Use verify<domtree> instead of intra-pass asserts.
Verifying dominator tree is expensive using intra-pass
asserts. Asserts added during D147408 are
increasing the build time of libc significantly. This change
does the verification after the atomic optimizer pass
and should fix the regression reported in D153232.

Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D153261
2023-06-20 09:52:58 -04:00
Weining Lu
2efdacf74c [LoongArch] Add missing chains and remove unnecessary SDNPSideEffect property for some intrinsic nodes 2023-06-20 21:16:26 +08:00
David Green
1d27ad2077 [AArch64] Add tablegen patterns for fp16 fcvtn2.
Similar to the existing f32 pattern, this adds a tablegen pattern for the fp16
fcvtn2.
2023-06-20 14:10:25 +01:00
Ivan Kosarev
2d3e6c4402 [AMDGPU] Drop GFX11 runs for dagcombine-fma-fmad.ll and fma.f16.ll.
They cause failures on the llvm-clang-x86_64-expensive-checks-debian
buildbot.

This partially reverts
D153269 [AMDGPU][GFX11] Add test coverage for FMA instructions.
2023-06-20 11:32:44 +01:00
Francesco Petrogalli
c7430ff9bf [CodeGen][test] Add missing REQUIRES.
Differential Revision: https://reviews.llvm.org/D153325
2023-06-20 12:00:07 +02:00
Ivan Kosarev
dec42ffa28 [AMDGPU][GFX11] Add test coverage for FMA instructions.
Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D153269
2023-06-20 10:50:03 +01:00
Francesco Petrogalli
37db9cae2b [llc][MISched] Add -misched-detail-resource-booking to llc.
The option `-misched-detail-resource-booking` prints the following
information every time the method
`SchedBoundary::getNextResourceCycle` is invoked:

1. counters of the resources that have already been booked;

2. the values returned by `getNextResourceCycle`, which is the next
available cycle in which a resource can be booked.

The method is useful to debug low-level checks inside the machine
scheduler that make decisions based on the values returned by
`getNextResourceCycle`.

Reviewed By: andreadb

Differential Revision: https://reviews.llvm.org/D153116
2023-06-20 11:46:27 +02:00
Francesco Petrogalli
25f8b1a0a8 Revert "[llc][MISched] Add -misched-detail-resource-booking to llc."
Reverting because of https://lab.llvm.org/buildbot#builders/75/builds/32485:

llvm-project/llvm/lib/CodeGen/MachineScheduler.cpp:2374:7: error: use of undeclared identifier 'MischedDetailResourceBooking'
 if (MischedDetailResourceBooking)

This reverts commit fc06262c1c365777e71207b6a5de281cba927c96.
2023-06-20 11:28:45 +02:00
Francesco Petrogalli
fc06262c1c [llc][MISched] Add -misched-detail-resource-booking to llc.
The option `-misched-detail-resource-booking` prints the following
information every time the method
`SchedBoundary::getNextResourceCycle` is invoked:

1. counters of the resources that have already been booked;

2. the values returned by `getNextResourceCycle`, which is the next
available cycle in which a resource can be booked.

The method is useful to debug low-level checks inside the machine
scheduler that make decisions based on the values returned by
`getNextResourceCycle`.

Reviewed By: andreadb

Differential Revision: https://reviews.llvm.org/D153116
2023-06-20 11:13:39 +02:00
Ben Shi
6d05f3f56e [CSKY] Optimize multiplication with immediates
Try to break a multiplication with a specific immediate to
an/a addition/subtraction of left shifts.

Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153106
2023-06-20 16:03:31 +08:00
Ben Shi
56e33d9881 [CSKY][test][NFC] Add more tests of multiplication with immediates
Reviewed By: zixuan-wu

Differential Revision: https://reviews.llvm.org/D153105
2023-06-20 16:03:15 +08:00
Bing1 Yu
516e32678d [X86][AMX] set Stride to Tile's Col when doing combine amxcast and store into tilestore
%tile = call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 32, i8* %src_ptr, i64 64)
%vec = call <256 x i8> @llvm.x86.cast.tile.to.vector.v256i8(x86_amx...%tile)
store <256 x i8> %vec, <256 x i8>* %dst_ptr, align 256
=>
%tile = call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 32, i8* %src_ptr, i64 64)
%stride = sext i16 32 to i64
call void @llvm.x86.tilestored64.internal(i16 8, i16 32, i8* %dst_ptr, i64 32, x86_amx %tile)

Reviewed By: LuoYuanke

Differential Revision: https://reviews.llvm.org/D153002
2023-06-20 11:55:25 +08:00
Fangrui Song
dafaa8463e [XRay] Make llvm.xray.customevent parameter type match __xray_customevent
The intrinsic has a smaller integer type than the parameter type of
builtin-function/API. Fix this similar to commit 3fa3cb408d8d0f1365b322262e501b6945f7ead9.
2023-06-19 20:38:16 -07:00
Fangrui Song
3fa3cb408d [XRay] Make llvm.xray.typedevent parameter type match __xray_typedevent
The Clang built-in function is void __xray_typedevent(size_t, const void *, size_t),
but the LLVM intrinsics has smaller integer types. Since we only allow
64-bit ELF/Mach-O targets, we can change llvm.xray.typedevent to
i64/ptr/i64.

This allows encoding more information and avoids i16 legalization for
many non-X86 targets.

fdrLoggingHandleTypedEvent only supports uint16_t event type.
2023-06-19 20:28:39 -07:00
Jay Foad
4b6d41cd1d [AMDGPU] Do not release VGPRs if there may be pending scratch stores
Differential Revision: https://reviews.llvm.org/D153295
2023-06-19 21:12:43 +01:00
Amy Kwan
d5659808b2 [AIX][TLS] Generate 64-bit local-exec access code sequence
This patch adds support for the TLS local-exec access model on AIX to allow
for the ability to generate the 64-bit (specifically, non-optimized) code sequence.

For this patch in particular, the sequence that is generated involves a load of the
variable offset, followed by an add of the loaded variable offset to r13 (which is
thread pointer, respectively). This code sequence looks like the following:
```
ld reg1,var[TC](2)
add reg2, reg1, r13     // r13 contains the thread pointer
```
The TOC (.tc pseudo-op) entries generated in the assembly files are also
changed where we add the @le relocation for the variable offset.

Differential Revision: https://reviews.llvm.org/D149722
2023-06-19 12:17:30 -05:00
Florian Hahn
dae5cd73cb
Recommit "[LSR] Consider post-inc form when creating extends/truncates."
This reverts the revert commit 1797ab36efc9c90c921cd725831f8c3f6a7125a2.

The recommitted version now checks the PostIncLoopSets for all fixups
and returns nullptr if the result doesn't match for all fixups.
2023-06-19 17:57:06 +01:00
Jeffrey Byrnes
ac2d6df2d6 [AMDGPU] Add basic support for extended i8 perm matching
Differential Revision: https://reviews.llvm.org/D142782

Change-Id: Ibb95224f7885839e8b77a705f487f10b47a258a6
2023-06-19 09:53:25 -07:00
Jay Foad
eb7491769a [AMDGPU] Reimplement the GFX11 early release VGPRs optimization
Implement this optimization in SIInsertWaitcnts, where we already have
information about whether there might be outstanding VMEM store
instructions. This has the following advantages:
- Correctly handles atomics-with-return.
- Correctly handles call instructions.
- Should be faster because it does not require running a separate pass.

Differential Revision: https://reviews.llvm.org/D153279
2023-06-19 17:12:54 +01:00
Matt Arsenault
7c8958118c AMDGPU: Remove amdgpu-waves-per-eu support in old attribute pass
AMDGPUAttributor now handles this attribute with value merging, so
delete the old approach which could only apply this to functions which
did not set it, or cloned the function.
2023-06-19 11:50:50 -04:00
Krzysztof Parzyszek
734881a6d5 [Hexagon] Fix range checks for immediate operands
The output assembly (textual) contains the instruction
  r29 = add(r29,#4294967136)
The value 4294967136 is -160 when interpreted as a signed 32-bit
integer, so it fits in the range of the immediate operand without
a constant extender. The range check in HexagonInstrInfo was putting
the operand value into an int variable, reporting no need for an
extender. This resulted in a packet with 4 instructions, including
the "add". The corresponding check in HexagonMCInstrInfo was using
an int64_t variable, causing the range check to fail, and an extender
to be emitted when lowering to MCInst, resulting in a packet with
too many instructions.
2023-06-19 08:22:41 -07:00
David Green
d0f56c3e5c [AArch64] Add and expand the testing of fmin/fmax reduction. NFC
For both CodeGen and CostModelling, this adds extran testing for the new
lvm.vector.reduce.fmaximum and lvm.vector.reduce.fminimum intrinsics, as well
as making sure there is test coverage for all the various cases.
2023-06-19 15:47:21 +01:00
David Green
16b46dde0b [AArch64] More tablegen patterns for addp of two extracts
Similar to D152245, this adds integer addp patterns, using the larger
v4i32 addp from addp extractlow, extracthi.
2023-06-19 07:52:46 +01:00
David Green
68f34e4d39 [AArch64] Add tablegen patterns for faddp of two extracts
This adds some simple tablegen patterns for converting
`faddp v2f32 extractlow(Rn), v2f32 extracthigh(Rn)` to
`faddp v4f32 Rn, v4f32 Rn` using the q variants of the
instructions, avoiding the extra ext needed to extract
the high lanes. Only the bottom lanes of the new faddp
are used, the second Rn operand is used as a placeholder.
It uses Rn to prevent any false dependencies, but could
equally by undef.

Differential Revision: https://reviews.llvm.org/D152245
2023-06-19 07:48:31 +01:00
Fangrui Song
b9a134aa62 [XRay] Mark Mach-O xray_instr_map and xray_fn_idx as S_ATTR_LIVE_SUPPORT
Add the `S_ATTR_LIVE_SUPPORT` attribute to the sections so that `ld -dead_strip`
will retain subsections that reference live functions, once we we add linker
private "l" symbols as atoms.
2023-06-18 19:30:16 -07:00
Jianjian GUAN
04ed822dcc [RISCV] Match shl (ext v, splat 1) to vector widening add.
Since we use match shl (v, splat 1) to vadd, we could also expand to widening add.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D153112
2023-06-19 09:46:36 +08:00
Fangrui Song
49b61ead47 [XRay][test] Make tests less sensitive to .Ltmp/Ltmp label changes 2023-06-18 13:32:40 -07:00
Simon Pilgrim
fb60dda189 [GlobalIsel][X86] selectDivRem - fix typo in 64-bit AH handling code
This function was lifted from fast-isel, and still referred to the Instruction::SRem/URrem opcodes, instead of the G_SREM/G_UREM opcodes.

But it turns out these aren't necessary at all as only the G_SREM/G_UREM codepaths will use the AH register for DivRemResultReg anyhow.
2023-06-18 17:37:17 +01:00
Simon Pilgrim
46479ea785 [GlobalIsel][X86] Regenerate srem/urem select test coverage 2023-06-18 17:06:32 +01:00
Yingwei Zheng
315e3001c0
[CodeGenPrepare][RISCV] Remove asserting VH references before erasing the dead GEP
Fixes issue https://github.com/llvm/llvm-project/issues/63365

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D153194
2023-06-18 23:40:47 +08:00
Simon Pilgrim
e1164c7a92 [X86] Regenerate tls.ll and reuse common linux check prefixes 2023-06-18 16:02:59 +01:00
Simon Pilgrim
d7464ea5e6 [X86] Regenerate add32ri8.ll 2023-06-18 16:02:59 +01:00
Krzysztof Parzyszek
5ad9adb9b0 [Hexagon] Add missing patterns for boolean [v]selects
Fixes https://github.com/llvm/llvm-project/issues/59663
2023-06-17 17:15:07 -07:00
Krzysztof Parzyszek
833438eef0 [Hexagon] Handle all compares of i1 and vNi1
Fixes https://github.com/llvm/llvm-project/issues/63363
2023-06-17 16:31:21 -07:00
Krzysztof Parzyszek
d1c3ec61d6 [Hexagon] Add missing patterns for truncate to vNi1 2023-06-17 16:31:21 -07:00
Florian Hahn
1797ab36ef
Revert "[LSR] Consider post-inc form when creating extends/truncates."
This reverts commit abfeda5af329b5889db709ff74506e20e0b569e9.
and fe19036e1266d2a90b44725c82b898134906e4c3.

The added assertion triggers during clang bootstrap builds. Revert while
I investigate.
2023-06-17 17:58:41 +01:00
Florian Hahn
fe19036e12
[AMDGPU] Update test after abfeda5af329b58. 2023-06-17 10:15:15 +01:00
Jay Foad
01b512882d [AMDGPU] Generate checks for load-constant tests
Differential Revision: https://reviews.llvm.org/D153139
2023-06-17 06:47:15 +01:00
Weining Lu
c216ce0ef8 [LoongArch] Fix handling of the chain of CSRWR and CSRXCHG nodes
`LoongArchISD::CSRWR` has two results. The first is the result of
`loongarch.csrwr.[wd]` intrinsic and the second is the chain. But
currently the chain is not processed correctly when creating this
node, resulting in the `csrwr` instruction being optimized out when
the result is not used by anyone [1]. `LoongArchISD::CSRXCHG` has
the same issue.

This patch addresses this issue.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/loongarch.h?h=v6.4-rc6#n219

Reviewed By: hev

Differential Revision: https://reviews.llvm.org/D153120
2023-06-17 10:49:18 +08:00
Weining Lu
4a69fd6269 [LoongArch][NFC] Precommit test for D153120 (the fix of CSRWR and CSRXCHG)
Reviewed By: xry111

Differential Revision: https://reviews.llvm.org/D153119
2023-06-17 10:49:17 +08:00
LiaoChunyu
12fee611ca [RISCV] Fold special case (xor (setcc constant, y, setlt), 1) -> (setcc y, constant + 1, setlt)
Improve D151719.
(xor (setcc constant, y, setlt), 1) -> (setcc y, constant + 1, setlt)
https://alive2.llvm.org/ce/z/BZNEia

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D152128
2023-06-17 10:10:20 +08:00
Philip Reames
95697deff3 [RISCV] Make all vector binops use the _TU pseudo form
This continues towards the goal spelled out in https://discourse.llvm.org/t/riscv-transition-in-vector-pseudo-structure-policy-variants/71295. This patch switches all the binary operations (no widen, no narrow, but both int and FP) to use the _TU + implicit_def passthrough form.  Change is mechanical.

This only changes the unmasked variants. Masked variants will still go through doPeepholeMaskedRVV and end up in the unsuffixed/TA form. Fixing that will be a separate change.

Differential Revision: https://reviews.llvm.org/D152940
2023-06-16 16:28:19 -07:00
Nitin John Raj
a986998bad [RISCV] Introduce RISCVISD::VWMACC(U/SU)_VL opcode
Differential Revision: https://reviews.llvm.org/D153057
2023-06-16 16:11:35 -07:00
Krzysztof Parzyszek
77e4c48ede [Hexagon] Generate correct instruction for store i1, ($Rs<<$u2 + $Rt)
Fixes https://github.com/llvm/llvm-project/issues/63359
2023-06-16 15:26:29 -07:00
Matt Arsenault
d9333e360a Revert "AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexp"
This reverts commit 1159c670d40e3ef302264c681fe7e0268a550874.

Accidentally pushed wrong patch
2023-06-16 18:13:07 -04:00
Matt Arsenault
1159c670d4 AMDGPU: Drop and auto-upgrade llvm.amdgcn.ldexp to llvm.ldexp 2023-06-16 18:06:27 -04:00
Krzysztof Parzyszek
4351060a2f [Hexagon] Properly combine overlapping stores in HVC 2023-06-16 13:29:19 -07:00