53417 Commits

Author SHA1 Message Date
Nuri Amari
8cc8e5d6c6
Run ObjCContractPass in Default Codegen Pipeline (#92331)
Prior to this patch, when using -fthinlto-index= the ObjCARCContractPass isn't run prior to CodeGen, and instruction selection fails on IR containing arc intrinsics. This patch is motivated by that usecase.

The pass was previously added in various places codegen is performed. This patch adds the pass to the default codegen pipepline, makes sure it bails immediately if no arc intrinsics are found, and removes the adhoc scheduling of the pass. 

Co-authored-by: Nuri Amari <nuriamari@fb.com>
2024-05-23 10:04:55 -07:00
Yingwei Zheng
558cb29fea
[GISel][RISCV] Legalize G_FREM (#93063)
This patch adds support for `G_FREM` on RISCV.
2024-05-24 00:34:06 +08:00
Phoebe Wang
a0e6f83781
[ConstraintFP] Model rounding control registers for inline asm (#92846)
We have an internal test affected by
a69673615b.
The reason is we haven't modeled rounding control registers for inline
asm under constraint FP.
Here is a reduced case:  https://godbolt.org/z/s4EsKP94e
2024-05-23 22:50:39 +08:00
Thorsten Schütt
9c60010a61
[GlobalIsel] Combine G_ADD and G_SUB (#92879) 2024-05-23 16:28:32 +02:00
YunQiang Su
0bf181eb34
MIPS: Fix llvm.{min,max}num for R6 (#93125)
MIPS max.fmt/min.fmt instructions is IEEE2008 compatiable. If either
argument is sNaN, the result will be NaN.

So we define fminnum_ieee instead of fminnum in Mips32r6InstrInfo.td. We
also should define fcanonicalize. So that we can define fminnum as
expand to fcanonicalize and fminnum_ieee.
2024-05-23 22:27:17 +08:00
Lukacma
90a469057e
Revert "[SME] Add intrinsics for FCVT(wid.) and FCVTL" (#93196)
Reverts llvm/llvm-project#90215
2024-05-23 15:13:14 +01:00
Lukacma
8dcbc4cfbf
Revert "[AArch64][SME] Add intrinsics for vector groups ZERO" (#93195)
Reverts llvm/llvm-project#88114
2024-05-23 15:12:46 +01:00
Matt Arsenault
2401b6126d
AMDGPU: Fix creating minimum3/maximum3 nodes pre-gfx12 (#93027)
These would fail to select.
2024-05-23 15:59:43 +02:00
Lukacma
7a1022a389
[AArch64][SME] Add intrinsics for vector groups ZERO (#88114)
According to the specification in
https://github.com/ARM-software/acle/pull/309 this adds the intrinsics:

```
  void svzero_za64_vg1x2(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg1x4(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg2x1(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg2x2(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg2x4(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg4x1(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg4x2(uint32_t slice)
    __arm_streaming __arm_inout("za");

  void svzero_za64_vg4x4(uint32_t slice)
    __arm_streaming __arm_inout("za");
```
2024-05-23 14:36:58 +01:00
Lukacma
05c154f2bc
[SME] Add intrinsics for FCVT(wid.) and FCVTL (#90215)
According to the specification in
https://github.com/ARM-software/acle/pull/309 this adds the intrinsics

```
svfloat32x2_t svcvt_f32[_f16_x2](svfloat16_t zn) __arm_streaming;
svfloat32x2_t svcvtl_f32[_f16_x2](svfloat16_t zn) __arm_streaming;

```
These are available only  if  __ARM_FEATURE_SME_F16F16 is enabled.

---------

Co-authored-by: Caroline Concatto <caroline.concatto@arm.com>
2024-05-23 14:32:34 +01:00
Matt Arsenault
f06c1ce860
AMDGPU: Clean up maximum3/minimum3 tests (#93025)
These were using patterns copied from older tests, before non-kernel
functions were supported and manually written checks. Also stop using
-flat-for-global, which only exists to try to share tests between SI/CI
and VI+.

This was also missing test coverage, we're incorrectly forming
maximum3/minimum3 pre-gfx12. This is a pre-commit before fixing that.
2024-05-23 15:30:12 +02:00
Hari Limaye
5b5af52bad
[AArch64] Extend efficient lowering of experimental.cttz.elts (#92114)
This patch extends support for more efficient lowering of the
experimental.cttz.elts intrinsic to fixed-width vector types, by first
creating an SVE predicate register mask from the fixed-width vector.
2024-05-23 12:46:09 +01:00
Simon Pilgrim
85b9826c34 [AMDGPU] Regenerate sad.ll test checks
Improve test checks for better codegen review of #92576
2024-05-23 12:17:11 +01:00
Simon Pilgrim
aefd2572a5
[DAG][X86] expandABD - add branchless abds/abdu expansion for 0/-1 comparison result cases (#92780)
If the comparison results are allbits masks, we can expand as `abd(lhs, rhs) -> sub(cmpgt(lhs, rhs), xor(sub(lhs, rhs), cmpgt(lhs, rhs)))`, replacing a sub+sub+select pattern with the simpler sub+xor+sub pattern.

This allows us to remove a lot of X86 specific legalization code, and will be useful in future generic expansion for the legalization work in #92576

Alive2: https://alive2.llvm.org/ce/z/sj863C
2024-05-23 11:07:35 +01:00
csstormq
8a3537bfef
[llvm][ScheduleDAG] SUnit::biasCriticalPath() does not find the critical path consistently (#93001)
Patch co-authored by AtariDreams (gfunni234@gmail.com).

Fixes #38037.

[AMDGPU] Update test results to fix build (#92982)
2024-05-23 17:27:07 +08:00
Dhruv Chawla
4c48b3cb5c
[GISel][CombinerHelper] Push freeze through non-poison-producing operands (#90618)
This combine matches the existing fold in InstCombine, i.e.
InstCombinerImpl::pushFreezeToPreventPoisonFromPropagating.

It tries to push freeze through an operand if the operand has only one
maybe-poison operand and all other operands are guaranteed non-poison,
and if the operation itself cannot generate poison (eg. add with nsw can
generate poison, even with non-poison operands).

This is beneficial because it can potentially enable other optimizations
to occur that would otherwise be blocked because of the freeze.
2024-05-23 13:45:52 +05:30
Yeting Kuo
7aa382fd72
[RISCV] Zicfilp implies Zicsr. (#93143)
The Zicfilp extension depends on the Zicsr extension.
Ref: https://github.com/riscv/riscv-cfi/blob/main/src/cfi_forward.adoc
2024-05-23 15:32:04 +08:00
Nikita Popov
ca478bc6cc
[SCEV] Support ule/sle exit counts via widening (#92206)
If we have an exit condition of the form IV <= Limit, we will first try
to convert it into IV < Limit+1 or IV-1 < Limit based on range info (in
icmp simplification). If that fails, we try to convert it to IV < Limit
+ 1 based on controlling exits in non-infinite loops.

However, if all else fails, we can still determine the exit count by
rewriting to ext(IV) < ext(Limit) + 1, where the zero/sign extension
ensures that the addition does not overflow.

Proof: https://alive2.llvm.org/ce/z/iR-iYd
2024-05-23 07:54:08 +02:00
Freddy Ye
aa4069ea96
Revert "[X86] Remove knl/knm specific ISAs supports (#92883)" (#93123)
This reverts commit 282d2ab58f56c89510f810a43d4569824a90c538.
2024-05-23 10:25:23 +08:00
Freddy Ye
282d2ab58f
[X86] Remove knl/knm specific ISAs supports (#92883)
Cont. patch after https://github.com/llvm/llvm-project/pull/75580
2024-05-23 09:46:44 +08:00
Philip Reames
25b65be43d
[RISCV][LSR] Account for temporary register for base addition (#92296)
An LSR formula may require the addition of multiple base or scale
registers, this sum reduction requires a temporary register to perform.
Since the formulas are independent, we only need one temporary,
regardless of the number of unique formula. Each formula can reuse the
same temporary. A later CSE pass may come along and combine
sub-expressions - but then the register pressure would be that passes
problem to consider.

This change fixes up the costing in the RISCV specific way, but this is
really a generic LSR problem. I just didn't feel like fighting with LSR
and dealing with all the various targets swinging slightly in hard to
reason about ways. This problem is more pronounced on RISCV than any
other target due to our lack of addressing modes.

This change is not hugely important on it's own, but I have an upcoming
change to add support fo shNadd in LSR which biases us fairly strongly
towards adding more "base adds". Without this change, we see net
regression due to the increase in register pressure which is not
accounted for.
2024-05-22 13:38:39 -07:00
Miguel Saldivar
6de14c61e4
[AArch64][SVE2] UZP should only have one result (#93041)
`UZP1` and `UZP2` are only expecting one result value, so this `getNode`
call should be updated to match that.

This is in response to #92779.
2024-05-22 21:34:03 +01:00
Jay Foad
990bed64fb
[AMDGPU] New intrinsic llvm.amdgcn.pops.exiting.wave.id (#89612)
This provides access to the special scalar source value
SRC_POPS_EXITING_WAVE_ID on GFX9 and GFX10.
2024-05-22 19:47:59 +01:00
David Green
0a62a99aa6
[SelectOpt] Add handling for not conditions. (#92517)
This patch attempts to help the SelectOpt pass detect select groups made
up of conditions and not(conditions). Usually these are canonicalized in
instcombine to remove the not and invert the true/false values, but this
will not happen for Loginal operations, which can be beneficial to
convert if they are part of a larger select group. The handling for
not's are mostly handled in the SelectLike, which can be marked as
Inverted in order to reverse the TrueValue and FalseValue.

This helps fix a regression in fortran minloc constructs, after #84628
helped simplify a loop with branches into a loop with selects.
2024-05-22 19:28:24 +01:00
Daniel Thornburgh
8baf96f306
Revert "[IR] Avoid creating icmp/fcmp constant expressions" (#93087)
Reverts llvm/llvm-project#92885 due to LLDB CI breakages.
2024-05-22 11:27:55 -07:00
Zaara Syeda
29456e9bcc
[PowerPC] Fix assembler error with toc-data and data-sections (#91976)
We should not emit the label for the toc-data variable when
data-sections=false.
2024-05-22 14:07:51 -04:00
Yingwei Zheng
f2bbb4cb3e
[GISel][RISCV] Legalize G_{U|S}DIVREM (#93067)
This patch expands `G_{U|S}DIVREM` into `G_{U|S}DIV + G_{U|S}REM`.
`G_{U|S}DIVREM` is generated by the following fold:

4ea21a0261/llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp (L1410-L1471)

It always folds `div + rem` pairs into `divrem` during pre-legalization.
I tried to change `isLegalOrBeforeLegalizer` to `isLegal`, but it
produced worse codegen on AArch64.
2024-05-23 01:26:48 +08:00
Craig Topper
135ddd80be
[X86] Remove unused MachineLoopInfo from X86FixupBWInsts. NFC (#92984) 2024-05-22 09:56:13 -07:00
Yingwei Zheng
c0de13b05f
[GISel][RISCV] Legalize shifts with non-trivial shamt types (#93019)
This patch widens the illegal shamt type `i48` -> `i64` to fix
legalization failure: https://godbolt.org/z/4zMTnoW7h
2024-05-22 23:36:34 +08:00
Yingwei Zheng
821bcba00d
[GISel] Add narrowScalar/widenScalar support for G_CONSTANT_FOLD_BARRIER (#93031)
Fixes an error that llc fails to legalize `G_CONSTANT_FOLD_BARRIER` with
i16/i128: https://godbolt.org/z/f9n6xM3sv
2024-05-22 23:35:37 +08:00
Jay Foad
154d93b7f2 [AMDGPU] Add a negative test for DPP combine into v_mul_lo_u32 2024-05-22 16:08:44 +01:00
Emma Pilkington
9e0be65f24
[AMDGPU] Fix broken MIR generated by gfx11 simulated trap lowering (#91652)
This was breaking the CFG connection between uses of virtual registers
after the trap and their definitions before it. Fixes SWDEV-460384.

Fixes a bug in #85854.
2024-05-22 10:55:19 -04:00
Yingwei Zheng
c8dc6b59d6
[SDAG] Improve SimplifyDemandedBits for mul (#90034)
If the RHS is a constant with X trailing zeros, then the X MSBs of the
LHS are not demanded.

Alive2: https://alive2.llvm.org/ce/z/F5CyJW
Fixes https://github.com/llvm/llvm-project/issues/56645.
2024-05-22 22:43:10 +08:00
Simon Pilgrim
f78febf7a8
[DAG] ComputeNumSignBits - add AVGCEILS/AVGFLOORS handling (#93021)
Pulled from #92096
2024-05-22 14:29:49 +01:00
Janek van Oirschot
a699ccbf0c
MCExpr-ify amd_kernel_code_t (#91587)
Redefines the amd_kernel_code_t struct with MCExprs for members that would be
derived from SIProgramInfo MCExpr members.
2024-05-22 13:45:45 +01:00
Yingwei Zheng
cf128305bd
[SDAG] Don't treat ISD::SHL as a uniform binary operator in ShrinkDemandedOp (#92753)
In `TargetLowering::ShrinkDemandedOp`, types of lhs and rhs may differ
before legalization.
In the original case, `VT` is `i64` and `SmallVT` is `i32`, but the type
of rhs is `i8`. Then invalid truncate nodes will be created.

See the description of ISD::SHL for further information:
> After legalization, the type of the shift amount is known to be
TLI.getShiftAmountTy(). Before legalization, the shift amount can be any
type, but care must be taken to ensure it is large enough.


605ae4e93b/llvm/include/llvm/CodeGen/ISDOpcodes.h (L691-L712)

This patch stops handling ISD::SHL in `TargetLowering::ShrinkDemandedOp`
and duplicates the logic in `TargetLowering::SimplifyDemandedBits`.
Additionally, it adds some additional checks like
`isNarrowingProfitable` and `isTypeDesirableForOp` to improve the
codegen on AArch64.

Fixes https://github.com/llvm/llvm-project/issues/92720.
2024-05-22 20:20:33 +08:00
Simon Pilgrim
bbc4c2e047 [DAG] SimplifyDemandedBits - ensure we have simplified the shift operands before folding to AVG
Pulled out of #92096 - ensure we have completed a topological simplification of the SRA/SRL shift operands before we try to combine to a AVG node, as its difficult to later simplify through AVG nodes.
2024-05-22 11:55:03 +01:00
Simon Pilgrim
6381cfe891 [X86] stack-frame-layout-remarks.ll - fix BOTH-Next -> BOTH-NEXT typo
Typo identified in #91854
2024-05-22 11:07:24 +01:00
Simon Pilgrim
1b06643708 [X86] stack-folding-fp-avx512fp16.ll - remove broken CHECK-LABEl prefix lines
Typo identified in #91854
2024-05-22 11:07:23 +01:00
Sven van Haastregt
89c23f7683
[SPIR-V] Add cl_khr_kernel_clock / SPV_KHR_shader_clock extension (#92771)
Recognize `cl_khr_kernel_clock` builtins and translate them to
`OpReadClockKHR` instructions. The `Scope` operand is deduced from the
builtin function name.

spirv-val does not pass yet due to OpReadClockKHR only supporting the
valid scopes for Vulkan (Device and Subgroup, but not Workgroup), so
leave validation disabled with a TODO.
2024-05-22 09:38:01 +02:00
Yingwei Zheng
235465e404
[RISCV][GISel] Legalize G_{U|S}{ADD|SUB}SAT (#92935)
This patch adds support for G_UADDSAT/G_SADDSAT/G_USUBSAT/G_SSUBSAT by
lowering it into add/sub with selects. When zbb is available,
min/max/minu/maxu will be selected.
2024-05-22 15:18:15 +08:00
Sander de Smalen
1015f51dd9
[AArch64] NFC: Rename -force-streaming-compatible-sve to -force-streaming-compatible (#92774)
The behaviour of the flag should be equivalent to
__arm_streaming_compatible.

At the moment, the name suggests that '-force-streaming-compatible-sve'
on its own (i.e. without specifying `+sve`) enables the compiler to use
the streaming-compatible subset of SVE instructions, but the semantics
merely are that the function can be called with either PSTATE.SM=0 or
PSTATE.SM=1.
2024-05-22 07:58:54 +01:00
Nikita Popov
1cf75cc77e Revert "[AMDGPU] Update test results to fix build (#92982)"
This reverts commit c769079b1098f6b108544176c0bd8b5bba986f2c.

This doesn't fix the build, it breaks it.
2024-05-22 08:49:38 +02:00
AtariDreams
c769079b10
[AMDGPU] Update test results to fix build (#92982) 2024-05-22 08:10:14 +02:00
Nikita Popov
108575f02e
[IR] Avoid creating icmp/fcmp constant expressions (#92885)
Do not create icmp/fcmp constant expressions in IRBuilder etc anymore,
i.e. treat them as "undesirable". This is in preparation for removing
them entirely.

Part of:
https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179
2024-05-22 07:40:08 +02:00
csstormq
7370b109b4
Revert "[llvm][ScheduleDAG] SUnit::biasCriticalPath() does not find the critical path consistently (#92368)" (#92992)
This reverts commit f0d1ae83b046ff0eeffc72a103f7c8b01ad33787.

This commit breaks tests: http://45.33.8.238/linux/138572/step_11.txt
2024-05-21 22:16:03 -07:00
csstormq
f0d1ae83b0
[llvm][ScheduleDAG] SUnit::biasCriticalPath() does not find the critical path consistently (#92368)
Fix https://github.com/llvm/llvm-project/issues/38037
2024-05-22 09:23:00 +08:00
Craig Topper
687039bce9
[X86] Return true for opaque constants in hasAndNotCompare. (#92944)
This is the X86 equivalent of #92926
2024-05-21 13:07:56 -07:00
Matt Arsenault
3c3e71d929 X86: Add regression test from issue #76416
Also add another testcase reported at the same regression commit. Make
sure this assert is fixed when the patch is eventually reapplied.
2024-05-21 20:22:17 +02:00
Zaara Syeda
194e7cc7aa
[PowerPC][AIX] 64-bit large code-model support for toc-data (#90619)
This patch adds support for toc-data for 64-bit large code-model on AIX.
The sequence ADDIStocHA8/ADDItocL8 is used to access the data directly
from the TOC.
When emitting the instruction ADDIStocHA8, we check if the symbol has
toc-data attribute before creating a toc entry for it. When emitting the
instruction ADDItocL8, we use the LA8 instruction to load the address.
2024-05-21 14:00:24 -04:00