45995 Commits

Author SHA1 Message Date
Philip Reames
c60a8d9af3 [RISCV] Add codegen coverage for select idioms which might benefit from XVentanaCondOps 2022-11-14 14:27:31 -08:00
Xiang Li
ad68c66a38 [DirectX backend] Fix build and test error caused by out of sync with upstream change.
Fix build and test error caused by
a2620e00ff#
and
304f1d59ca

Reviewed By: beanz

Differential Revision: https://reviews.llvm.org/D137815
2022-11-14 12:50:23 -08:00
Guozhi Wei
11e86868c1 [MachineCSE] Allow CSE for instructions with ignorable operands
Ignorable operands don't impact instruction's behavior, we can safely do CSE on
the instruction.

It is split from D130919. It has big impact to some AMDGPU test cases.
For example in atomic_optimizations_raw_buffer.ll, when trying to check if the
following instruction can be CSEed

  %37:vgpr_32 = V_MOV_B32_e32 0, implicit $exec

Function isCallerPreservedOrConstPhysReg is called on operand "implicit $exec",
this function is implemented as

  -  return TRI.isCallerPreservedPhysReg(Reg, MF) ||
  +  return TRI.isCallerPreservedPhysReg(Reg, MF) || TII.isIgnorableUse(MO) ||
            (MRI.reservedRegsFrozen() && MRI.isConstantPhysReg(Reg));

Both TRI.isCallerPreservedPhysReg and MRI.isConstantPhysReg return false on this
operand, so isCallerPreservedOrConstPhysReg is also false, it causes LLVM failed
to CSE this instruction.

With this patch TII.isIgnorableUse returns true for the operand $exec, so
isCallerPreservedOrConstPhysReg also returns true, it causes this instruction to
be CSEed with previous instruction

  %14:vgpr_32 = V_MOV_B32_e32 0, implicit $exec

So I got different result from here. AMDGPU's implementation of isIgnorableUse
is

  bool SIInstrInfo::isIgnorableUse(const MachineOperand &MO) const {
    // Any implicit use of exec by VALU is not a real register read.
    return MO.getReg() == AMDGPU::EXEC && MO.isImplicit() &&
           isVALU(*MO.getParent()) && !resultDependsOnExec(*MO.getParent());
  }

Since the operand $exec is not a real register read, my understanding is it's
reasonable to do CSE on such instructions.

Because more instructions are CSEed, so I get less instructions generated for
these tests.

Differential Revision: https://reviews.llvm.org/D137222
2022-11-14 19:34:59 +00:00
Yashwant Singh
1c9a93ae3a [GlobalIsel][AMDGPU] Changing legalize rule for G_{UADDO|UADDE|USUBO|USUBE|SADDE|SSUBE}
Generic add and sub with carry are now legalized in a way to explicitly calculate carry/borrow output. i.e
%6:_(s64), %7:_(s1) = G_UADDO %0, %1
becomes,
%13:_(s32), %14:_(s1) = G_UADDO %2, %4
%15:_(s32), %16:_(s1) = G_UADDE %3, %5, %14
%6:_(s64) = G_MERGE_VALUES %13(s32), %15(s32)
%7:_(s1) = G_ICMP intpred(ult), %6(s64), %1

Here G_MERGE and G_ICMP instructions are redundant for recalculating carry output. (Similar case for sub with borrow)
This change fix this.

Reviewed By: arsenm, #amdgpu

Differential Revision: https://reviews.llvm.org/D137932
2022-11-14 23:42:23 +05:30
Craig Topper
637ed52d9d [RISCV] Remove old test case. NFC
This seemed to be testing a pattern for an RV64 Zbp instruction, but
on RV32. On RV32, it's just swizzling registers so isn't very
interesting.
2022-11-14 09:36:44 -08:00
Craig Topper
13e32a8a3c [RISCV] Improve use of PACK instruction on rv64.
Handle the case where the lower bits come from a zero extending
load or other operation with known zero bits.
2022-11-14 09:36:33 -08:00
Sanjay Patel
cd7ff0707f [SystemZ] improve test for showing store merge miscompile; NFC
See issue #58883 for details.
2022-11-14 12:09:15 -05:00
Philip Reames
780c539844 [RISCV] Implement assembler support for XVentanaCondOps
This change provides an implementation of the XVentanaCondOps vendor extension. This extension is defined in version 1.0.0 of the VTx-family custom instructions specification (https://github.com/ventanamicro/ventana-custom-extensions/releases/download/v1.0.0/ventana-custom-extensions-v1.0.0.pdf) by Ventana Micro Systems.

In addition to the technical contribution, this change is intended to be a test case for our vendor extension policy.

Once this lands, I plan to use this extension to prototype selection lowering to conditional moves. There's an RVI proposal in flight, and the expectation is that lowering to these and the new RVI instructions is likely to be substantially similar.

Differential Revision: https://reviews.llvm.org/D137350
2022-11-14 09:01:54 -08:00
Nicholas Guy
62b00bf1af [NFC] Removal of complex deinterleaving test case complex_mul_v8f64
This test is not particularly useful for testing complex deinterleaving,
 especially due to f64 muls not being supported in mve. The test is
 being removed as it's hitting an unrelated pre-existing condition
 regarding register spilling.
2022-11-14 15:58:14 +00:00
Ivan Kosarev
1b560e6ab7 [AMDGPU][MC] Support TFE modifiers in MUBUF loads and stores.
Reviewed By: dp, arsenm

Differential Revision: https://reviews.llvm.org/D137783
2022-11-14 15:36:18 +00:00
Sjoerd Meijer
cc5f93bb49 [AArch64] Add match patterns for the reassociated forms of FNMUL
Differential Revision: https://reviews.llvm.org/D137925
2022-11-14 20:02:36 +05:30
Nicholas Guy
d52e2839f3 [ARM][CodeGen] Add support for complex deinterleaving
Adds the Complex Deinterleaving Pass implementing support for complex numbers in a target-independent manner, deferring to the TargetLowering for the given target to create a target-specific intrinsic.

Differential Revision: https://reviews.llvm.org/D114174
2022-11-14 14:02:27 +00:00
Craig Topper
3b75979806 [RISCV] Add PACKH/PACKW/PACK to hasAllNBitUsers. 2022-11-13 23:57:52 -08:00
Craig Topper
3ac93d1f2f [RISCV] Add another PACKH pattern.
This handles the case where the upper bits are zeroed with an AND
after the OR.
2022-11-13 23:57:52 -08:00
Craig Topper
40ae4b8903 [RISCV] Improve PACKH instruction selection
Handle AssertZExt in addition to AND.
2022-11-13 21:58:45 -08:00
wangpc
c66b69777c [RISCV] Don't use zero-stride vector load if there's no optimized u-arch
For vector strided instructions, as the RVV spec says:

> When rs2=x0, then an implementation is allowed, but not required, to
> perform fewer memory operations than the number of active elements, and
> may perform different numbers of memory operations across different
> dynamic executions of the same static instruction.

So compiler shouldn't assume that fewer memory operations will be
performed when rs2=x0.

We add a target feature to specify whether u-arch supports optimized
zero-stride vector load. And we do vector splat optimization iff this
feature is supported.

This feature is enabled by default since most designs implement this
optimization.

Reviewed By: reames

Differential Revision: https://reviews.llvm.org/D137699
2022-11-14 13:51:30 +08:00
Craig Topper
1a8ba9e19f [RISCV] Improve selection of PACKW.
Use hasAllWUsers to check if the upper bits are ignored so we can
use PACKW even when no sign_extend_inreg is present before the OR.
2022-11-13 18:37:37 -08:00
gonglingqin
19ae5391e3 [LoongArch] Expand atomicrmw fadd/fsub/fmin/fmax with CmpXChg
Differential Revision: https://reviews.llvm.org/D137311
2022-11-14 10:11:37 +08:00
Craig Topper
03f9009cbf [RISCV] Fix incorrect early out from isSignExtendedW in RISCVSExtWRemoval.
We can only return false to abort. If the criteria is met we need
to use continue instead. Returning true stops us from visiting all
nodes and makes the caller think it is safe to remove sext.w.
2022-11-13 17:30:39 -08:00
Craig Topper
fe0d4ba373 [RISCV] Add test for incorrect sext.w removal. NFC 2022-11-13 17:30:39 -08:00
Craig Topper
95388f7329 [RISCV] Improve selection of PACK/PACKW for AssertZExt input. 2022-11-13 16:00:45 -08:00
Krzysztof Parzyszek
475d22895a [Hexagon] Reduce the spill alignment for double/quad vector classes
The spill alignment for HVX vectors is always the single vector size,
regardless of whether the class describes vector tuples or not.
2022-11-13 14:02:36 -06:00
Simon Pilgrim
d9bff27024 [X86] Regenerate combine-movmsk.ll
Adds a AVX check that we lost at some point
2022-11-13 17:12:22 +00:00
chenglin.bi
8482247900 [GlobalISel] Correct constant type in matchReassocConstantInnerLHS
When we match a pattern from m_GCst, the register type could be different from original op. So we can't replace the original op to vreg direct.
This code create a new constant with original op type then replace the original op.

Fix #58906

Reviewed By: arsenm, aemerson

Differential Revision: https://reviews.llvm.org/D137778
2022-11-13 19:20:07 +08:00
zhongyunde
894f9e54f5 [AArch64] Optimize more memcmp when the result is tested for [in]equality with 0
We already surpport the or (xor a, b), (xor c, d) with D136244, while it should
capture more cases than just bcmp according the comment on
https://reviews.llvm.org/D136672, so this patch try to fold continuous
comparison series.

Also add a new callsite in LowerSETCC to address some cases folded And in the
stage of `Optimized type-legalized selection`.
Depends on D136244

Reviewed By: dmgreen, bcl5980
Differential Revision: https://reviews.llvm.org/D137721
2022-11-13 11:02:34 +08:00
Matt Arsenault
0a376d1034 AMDGPU: Add some tests for i1 sitofp/uitofp-like selects 2022-11-12 10:36:55 -08:00
Matt Arsenault
5247ae9de5 AMDGPU: Switch some tests to generated checks 2022-11-12 10:29:47 -08:00
Krzysztof Parzyszek
a03e16a16e [Hexagon] Improve idioms for fixed-point vector multiplication
Make the code more general, restore the ability to generate V6_vmpyhvsrs.
2022-11-12 08:46:27 -08:00
David Green
e6434113a5 [AArch64] Allow sinking both extract and splat to smull
We currently will sink either a splat or two extracts to a smull/umull.
There can be cases where we have both one operand as an extract and one
as a splat. This alters the areExtractShuffleVectors method to account
for that case.

Differential Revision: https://reviews.llvm.org/D137726
2022-11-12 16:41:15 +00:00
Amara Emerson
2179f51335 [AArch64][GlobalISel] Select TBZ for icmp sge x, 0.
This results in some nice size improvements on -Os CTMark:
Program                                       size.__text
                                              sdag           gisel           diff
consumer-typeset/consumer-typeset             414124.00      414052.00      -0.0%
tramp3d-v4/tramp3d-v4                         356840.00      356732.00      -0.0%
lencod/lencod                                 427560.00      427396.00      -0.0%
7zip/7zip-benchmark                           568400.00      568172.00      -0.0%
Bullet/bullet                                 455660.00      455428.00      -0.1%
mafft/pairlocalalign                          248236.00      248040.00      -0.1%
sqlite3/sqlite3                               284404.00      284176.00      -0.1%
ClamAV/clamscan                               381052.00      380604.00      -0.1%
SPASS/SPASS                                   411932.00      411296.00      -0.2%
kimwitu++/kc                                  439696.00      438992.00      -0.2%
                           Geomean difference                               -0.1%
2022-11-11 20:15:46 -08:00
Alina Sbirlea
57dbca20ea Revert "[Hexagon] Use default attributes for intrinsics"
This reverts commit 8a8983b279dd5e4dceabe1fadbb8980b6adb88f9.

Uncovers existing regalloc issue in Hexagon backend - blocking for Halide
Hexagon users. Reverting to unblock, to be recommitted when underlying issue is resolved.
Reproducer available shortly.
2022-11-11 15:10:05 -08:00
Mingming Liu
0f9ef8b180 [AArch64] Select BFI/BFXIL to ORR with shifted operand when one operand is the left or right shift of another operand
Use right shift [1] as an example
- Before, bfxil is generated (https://godbolt.org/z/EfzWMszPn)
- After, orr with right-shifted operand is generated (added test cases in `CodeGen/AArch64/bitfield-insert.ll`)

[1]
```
define i64 @test_orr_not_bfxil_i64(i64 %0) {
  %2 = and i64 %0, 1044480 ; 0xff000
  %3 = lshr i64 %2, 12
  %4 = or i64 %2, %3
  ret i64 %4
}
```

Differential Revision: https://reviews.llvm.org/D137689
2022-11-11 14:01:02 -08:00
Mingming Liu
3acbaddd43 [NFC][AArch64]Precommit test cases to show ORR is better when one operand is a shift of the other operand
In `bfi-not-orr` tests, bfi/bfxil are better since they simplifies away two instructions (extracting bits into destination directly)

In `orr-not-bfi` tests, orr is better since both orr and bfm would simplify away one instruction (the shl node), orr has higher throughput and shorter latency than bfm.
2022-11-11 14:01:02 -08:00
Krzysztof Parzyszek
017186294d [Hexagon] Place aligned loads closer to users
Vector alignment code was grouping all aligned loads together. In some
cases the groups could become quite large causing a lot of spill to be
generated. This will place the loads closer to where they are used,
reducing the register pressure.
2022-11-11 12:04:33 -08:00
Benjamin Maxwell
bd27ac4298 Precommit for redundant and after SVE load 2022-11-11 15:29:04 +00:00
wanglei
882ddab4c0 [LoongArch] Generate PCALAU12I + JIRL instruction pair for medium codemodel
In LoongArch, when `CodeModel=Medium`, it just increases the jumping
ability of function calls relative to PC, from 2^28 to 2^32.

Depends on D137393

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137394
2022-11-11 18:26:51 +08:00
wanglei
4edcf8ab9f [LoongArch] Moved expansion of PseudoCALL to LoongArchPreRAExpandPseudo pass
This patch moves the expansion of the `PseudoCALL` insturction to
`LoongArchPreRAExpandPseudo` pass. This helps to expand into different
instruction sequences according to different CodeModels.

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137393
2022-11-11 18:04:56 +08:00
Nikita Popov
8a8983b279 [Hexagon] Use default attributes for intrinsics
This switches Hexagon intrinsics to use the default attributes
(nosync, nofree, nocallback and willreturn). Especially willreturn
is needed to prevent optimization regressions in the future.

The only intrinsics I've excluded here are the load/store locked
intrinsics, which presumably aren't nosync.

Differential Revision: https://reviews.llvm.org/D137623
2022-11-11 10:59:00 +01:00
David Green
a1e799288d [AArch64] Add smull sinking extract-and-splat tests and regenerate neon-vmull-high-p8.ll. NFC 2022-11-11 08:27:44 +00:00
Craig Topper
bc6666a751 [RISCV] Remove unused CHECK lines from test. NFC
These aren't included in the check-prefixes.
2022-11-10 22:39:32 -08:00
gonglingqin
da34aff90d [Clang][LoongArch] Implement __builtin_loongarch_crc_w_d_w builtin and add diagnostics
This patch adds support to prevent __builtin_loongarch_crc_w_d_w from compiling
on loongarch32 in the front end and adds diagnostics accordingly.

Reference: https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/larchintrin.h#L175-L184

Depends on D136906

Differential Revision: https://reviews.llvm.org/D137316
2022-11-11 09:16:57 +08:00
zhongyunde
ffb109b685 [AArch64][SVE] Support logical operation BIC with DestructiveBinary patterns
Logical operation BIC with DestructiveBinary patterns is temporarily removed as
causes an assert (commit 3c382ed71f15), so try to fix that.
The most significant being that for pseudo instructions that do not have real instructions (including movpfx'd ones) that cover all combinations of register allocation, their expansion will be broken. This is the main reason the zeroing is an experimental feature because it has known bugs.
So we add an extra LSL for movprfx expand BIC_ZPZZ_ZERO A, P, A, A when necessary.
  movprfx	z0.s, p0/z, z0.s
  lsl z0.b, p0/m, z0.b, #0
  bic	z0.s, p0/m, z0.s, z0.s

Depends on D88595
2022-11-11 09:15:50 +08:00
Nick Desaulniers
6a8d894ce0 [CodeGen][Test] simplify callbr-asm-outputs.ll with nounwind NFC
The CFI directives add noise to the test. Remove them via nounwind fn
attrs. Also remove clobbers.

Reviewed By: void

Differential Revision: https://reviews.llvm.org/D137596
2022-11-10 14:23:09 -08:00
Sanjay Patel
244ac4fb1d [SystemZ] add test for mergeTruncStores miscompile; NFC
This is based on the example in issue #58883. I'm not sure
if the output currently shows the potential miscompile,
so we may want to adjust the test in a follow-up.
2022-11-10 14:11:32 -05:00
Matt Arsenault
1ab3d30e62 AArch64/GlobalISel: Regenerate some test checks to include -NEXT 2022-11-10 11:02:51 -08:00
Matt Arsenault
9fe5ca9b30 AArch64/GlobalISel: Regenerate test checks 2022-11-10 09:05:26 -08:00
Hassnaa Hamdi
22eef90be5 [AArch64][SVE][NFC] Add streaming mode SVE tests
Add sve-fixed-length testing files and enable streaming mode flag for:
and-combine.ll
bitcast.ll
reshuffle.ll
rev.ll
sdiv-pow2.ll
splat-vector.ll
int-extends.ll

Differential Revision: https://reviews.llvm.org/D137093
2022-11-10 13:51:09 +00:00
wanglei
d20c54cbdb [LoongArch] Override TargetFrameLowering::spillCalleeSavedRegisters
When using `llvm.returnaddress` intrinsic, special handling is required
for the spill of the `RA` register. Otherwise it will cause the verifier
fail in some cases (e.g. pr17377.c of the GCC C Torture Suite).

Specifically:
```
*** Bad machine code: Using an undefined physical register ***
- function:    f
- basic block: %bb.0 entry (0xd94d18)
- instruction: ST_D killed $r1, $r22, -40 :: (store (s64) into %stack.2)
- operand 0:   killed $r1
```

Reviewed By: SixWeining

Differential Revision: https://reviews.llvm.org/D137387
2022-11-10 21:14:27 +08:00
wanglei
0436cf5f52 [LoongArch] Support parsing target specific flags for MIR
These hooks ensure that the LoongArch backend can serialize and parse
MIR correctly.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D137482
2022-11-10 20:53:20 +08:00
Hassnaa Hamdi
956489700e [AArch64-SVE]: Force generating code compatible to streaming mode.
When streaming mode is enabled, custom-lower arithmetic and logical fixed-width vector ops;
to force generateing code compatible to streaming mode.

Differential Revision: https://reviews.llvm.org/D135324
2022-11-10 12:38:26 +00:00