47351 Commits

Author SHA1 Message Date
Matt Arsenault
cd60bff329 CodeGen: Add some additional is_fpclass lowering tests
Cover more cases in preparation for making greater use
of fcmp based lowerings. Also add more tests for the inverted
cases. Test iszero | isnan test masks. We should probably just
generate every combination of test masks.
2023-03-15 01:13:08 -04:00
Yeting Kuo
9637e950cb [RISCV] Support ISD::STRICT_FADD/FSUB/FMUL/FDIV for vector types.
The patch handles fixed type strict-fp by new RISCVISD::STRICT_ prefixed
isd nodes.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D145900
2023-03-15 07:47:16 +08:00
Julian Lettner
e6a789ef9b Remove -lower-global-dtors-via-cxa-atexit flag
Remove the `-lower-global-dtors-via-cxa-atexit` escape hatch introduced
in D121736 [1], which switched the default lowering of global
destructors on MachO to use `__cxa_atexit()` to avoid emitting
deprecated `__mod_term_func` sections.

I added this flag as an escape hatch in case the switch causes any
problems.  We didn't discover any problems so now we can remove it.

[1] https://reviews.llvm.org/D121736

rdar://90277838

Differential Revision: https://reviews.llvm.org/D145715
2023-03-14 14:18:11 -07:00
Craig Topper
c09730c23e [RISCV] Pre-commit tests for D145897. NFC 2023-03-14 13:11:11 -07:00
Jonas Paulsson
f8803919ad [SystemZ] Clear NW flags on an ISD::SUB when reused as comparison.
The SystemZ backend will try to reuse an existing subtraction of two values
whenever they are to be compared for equality. This depends on the SystemZ
subtraction instruction setting the condition code, which can also signal
overflow.

A later pass will remove the compare and reuse the CC from the subtraction
directly. However, if that subtraction has the NSW flag set it will not
include the overflow bit in the updated CC user. That was a bug which can
lead to wrong results, as shown by a csmith program.

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

Reviewed By: nikic, uweigand

Differential Revision: https://reviews.llvm.org/D145811
2023-03-14 19:46:41 +01:00
Alex Bradbury
084e413893 [RISCV] Fix regression due to interaction of MachineOutliner and MachineCopyPropagation
D144535 enabled machine copy propagation for RISC-V and added it to the
pass pipeline in addPreEmitPass2 (after the MachineOutliner).
Unfortunately, the MachineCopyPropagation pass is unable to correctly
analyse outlined functions, and will delete copy instructions where a
register is set that is intended to be live-out.
RISCVInstrInfo::buildOutlinedFrame will directly insert a JALR, while a
similar function going through the normal codegen path would have a
PseudoRet with operands indicating registers that are live-out.

This patch does the simplest fix, which is to run MachineCopyPropagation
before the MachineOutliner.

Differential Revision: https://reviews.llvm.org/D146037
2023-03-14 17:55:11 +00:00
Paul Walker
62e46f2621 [LLVM] Remove support for constant scalable vector GEPs.
This work has fallen out from D134648 as a requirement to loosen
the "constness" of vscale.

Differential Revision: https://reviews.llvm.org/D145404
2023-03-14 16:48:33 +00:00
Simon Pilgrim
cb47e254e5 [X86] Add test coverage for D137388
Issue #58914 reported an example of the TwoAddressInstruction crash that was fixed (without test case) in D137388
2023-03-14 15:26:39 +00:00
Simon Pilgrim
da570ef1b4 [DAG] Match select(icmp(x,y),sub(x,y),sub(y,x)) -> abd(x,y) patterns
Pulled out of PowerPC, and added ABDS support as well (hence the additional v4i32 PPC matches)

Differential Revision: https://reviews.llvm.org/D144789
2023-03-14 15:10:30 +00:00
Simon Pilgrim
4bf004e07e [DAG] Fold (bitcast (logicop (bitcast x), (c))) -> (logicop x, (bitcast c)) iff the current logicop type is illegal
Try to remove extra bitcasts around logicops if we're dealing with illegal types

Fixes the regressions in D145939

Differential Revision: https://reviews.llvm.org/D146032
2023-03-14 14:41:11 +00:00
Simon Pilgrim
f652bfeba5 [X86] Fix typo in vXi64 ABDS/ABDU test cases
The select operands were commuted preventing D144789 from folding
2023-03-14 14:32:19 +00:00
pvanhout
1f1fea6c38 Reland: [DAG/AMDGPU] Use UniformityAnalysis in DAGISel
Switch DAGISel over to UniformityAnalysis, which was one of the last remaining users of the DivergenceAnalysis.
No explosions seen during internal testing so this looks like a smooth transition.

Reviewed By: sameerds

Differential Revision: https://reviews.llvm.org/D145918
2023-03-14 14:38:45 +01:00
pvanhout
0ea6f0e158 [AMDGPU] Don't run llc-pipeline.ll when expensive_checks are enabled
AMDGPU ISel can add extra passes when expensive checks are enabled. This means the pipeline can be reordered and the checks may fail.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D146038
2023-03-14 14:12:36 +01:00
LiaoChunyu
eb54254b6e [RISCV] Return false from shouldFormOverflowOp when type is i8 and i16
i8 and i16 are not using overflow.
Reduce the number of zero extension instructions.

To reduce the uncertainty of the unknown,
most of the checks of the virtual function are kept

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D143646
2023-03-14 20:42:55 +08:00
Nicholas Guy
96615c856d [Codegen][ARM][AArch64] Support symmetric operations on complex numbers
Differential Revision: https://reviews.llvm.org/D142482
2023-03-14 12:11:10 +00:00
Nabeel Omer
2ebbcfa07e [X86] Fix encoding for ATOMIC_LOGIC_OP
Fixes PR#61384.

Differential Revision: https://reviews.llvm.org/D145930
2023-03-14 11:39:43 +00:00
Nabeel Omer
d8c2a10297 [X86] Add negative test for D145930
This patch adds a negative test for the issue discovered in D145930.

Differential Revision: https://reviews.llvm.org/D145933
2023-03-14 11:29:38 +00:00
Alex Bradbury
0246c61484 [RISCV][test] Test case for regression when MachineOutliner and MachineCopyPropagation are both enabled
MachineCopyPropagation removes a register copy in the outlined function
as it doesn't see that it's live-out from the function.
2023-03-14 11:18:21 +00:00
pvanhout
0e79106fc9 Revert "[DAG/AMDGPU] Use UniformityAnalysis in DAGISel"
This reverts commit 0022b5803fd4f5a4e9fcf233267c0ffa1b88f763.
2023-03-14 11:48:58 +01:00
pvanhout
0022b5803f [DAG/AMDGPU] Use UniformityAnalysis in DAGISel
Switch DAGISel over to UniformityAnalysis, which was one of the last remaining users of the DivergenceAnalysis.
No explosions seen during internal testing so this looks like a smooth transition.

Reviewed By: sameerds

Differential Revision: https://reviews.llvm.org/D145918
2023-03-14 11:18:28 +01:00
Chen Zheng
a3b57bca97 [PowerPC] remove side effect for some cases for saturate instructions
Fixes #60684

Reviewed By: nemanjai

Differential Revision: https://reviews.llvm.org/D145353
2023-03-13 21:37:56 -04:00
Chen Zheng
a81ba80eb0 add testcases for D145353; NFC 2023-03-13 21:37:49 -04:00
Michal Paszkowski
dc4330a925 [SPIR-V] Promote arbitrary width ints to regular width
After this patch all arbitrary size integers (smaller than 64 bits) in
LLVM IR will be promoted to regular size type in SPIR-V (OpTypeInt
8/16/32/64).

Differential Revision: https://reviews.llvm.org/D145137
2023-03-13 22:44:47 +01:00
Felipe de Azevedo Piovezan
dde08c9c48 [AArchExpandPseudo] Preserve instruction debug number in expansions
This is an initial attempt at preserving debug information in the pseudo
instruction expansion of the AArch backend. In particular, we preserve
the instruction number required by the InstrRef implementation of live
debug values.

There are many other expansions that need to be considered, but the ones
addressed in this commit should be extremely common, as they handle most
arithmetic and logical instructions.

Differential Revision: https://reviews.llvm.org/D145943
2023-03-13 15:29:15 -04:00
Hassnaa Hamdi
40a51e1afc [AArch64][SVE]: custom lower AVGFloor/AVGCeil.
-Lower AVGFloor(A, B) to:
 SRL(A) + SRL(B) + (A&B)&1.
-Lower AVGCeil(A, B) to:
 SRL(A) + SRL(B) + (A|B)&1.

Differential Revision: https://reviews.llvm.org/D143283
2023-03-13 19:00:57 +00:00
Yonghong Song
db3d2adecb [BPF] Improve pruning to avoid generate more types in BTF
Commit 3671bdbcd214("[BPF] Fix a BTF type pruning bug") fixed a
pruning bug to allow generate more types. But the commit has a bug
which permits to generate more types than necessary. The following
is an example to illustrate the problem.

   struct t1 {
     int a;
   };
   struct t2 {
     struct t1 *p1;
     struct t1 *p2;
     int b;
   };
   int foo(struct t2 *arg) {
     return arg->b;
   }

The following is the part of BTF generation sequence:
  (1). 'struct t2 *arg' -> 'struct t1 *p1'
       In this step, the type 'struct t1' will be generated as
       a forward decl and the ptr type (to 'struct t1') will
       be stored in the internal type table.
  (2). now the second field 'struct t1 *p2' will be processed.
       Since the ptr type (to 'struct t1') already in the type
       table, the existing logic strips out ptr modifier and
       is able to generate BTF type for 'struct t1'.

In the above step (2), if CheckPointer is true (the type traversal
chain including a struct member), 'ptr' modifier should be checked
and the subsequent type generation should be skipped since
the same case has been processed in visitDerivedType().

The issue is exposed when I am trying to use llvm15 to compile
some internal bpf programs. The bpf skeleton put the whole
ELF section (after striping some sections like dwarf) as a string.
The large BTF section triggered the following error:

  bpf_object_with_struct_ops_test_prog_bpf/BpfObjectWithStructOpsTestProg.skel.h:222:23:
  error: string literal of length 140144 exceeds maximum length 65536 that C++ compilers
  are required to support [-Werror,-Woverlength-strings]
        return (const void *)"\
                             ^~
  1 error generated.

Although adding -Wno-overlength-strings could workaround the issue,
improving llvm BTF generation sounds better esp. for users using vmlinux.h.

Differential Revision: https://reviews.llvm.org/D145816
2023-03-13 09:34:37 -07:00
Phoebe Wang
7ff0b9735d [X86] Use llvm::Align for passing the alignment
This should be a typo in `emitConstantSizeRepmov`. Both its caller and
callee store the alignment in a 64-bit variables, no reason to truncate
it to 32-bit. It results in alignment turns into 0 when larger than
0x100000000.

Fixes #61348

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D145863
2023-03-14 00:06:21 +08:00
Felipe de Azevedo Piovezan
6e861d818a [MachineCombiner] Preserve debug instruction number
Each target's `TargetInstrInfo` is responsible for announcing which code
patterns it is able to transform during the MachineCombiner pass.
Currently, these patterns are applied without preserving the debug
instruction number required by the InstrRef implementation of
LiveDebugValues. As such, we've seen a number of examples where debug
information is dropped for variables in InstrRef mode that were
otherwise available in VarLoc mode. This has been observed both in X86
and AArch examples.

This commit is an initial attempt at preserving said numbers by changing
the general (target agnostic) implementation of TargetInstrInfo: the
reassociation pattern must keep the debug number of the "top level"
instruction, i.e., the instruction whose value represents the final
value of the arithmetic expression. Intermediate values must have their
debug number dropped, as they have no equivalent value in the
unoptimized code.

Future work is required to update each target's
`TargetInstrInfo::genAlternativeCodeSequence` method.

Differential Revision: https://reviews.llvm.org/D145759
2023-03-13 09:29:30 -04:00
Paul Walker
3870857226 [SVE] Restrict cmp+and->pred_cmp isel to instances where the and is the sole user of the compare.
Without the single use restriction we may replace the and with a
more costly duplicated compare.

Differential Revision: https://reviews.llvm.org/D145755
2023-03-13 12:42:00 +00:00
Phoebe Wang
afdcf219ea [X86] Pre-commit test for #61271 2023-03-13 16:39:08 +08:00
Craig Topper
bf4b9857d0 Recommit "[RISCV] Add separate lookup tables for fli.h and fli.d."
Fix mistake in f16 table in previous patch.

Original commit message:
Use separate lookup tables instead of trying to reuse the fli.s
table.

We were missing the 2 denormal cases for fli.h. We also had an issue
where fli.d was only checking 8 bits of the 11 bit exponent.
2023-03-12 22:17:56 -07:00
Craig Topper
ffc18c3339 Revert "[RISCV] Add separate lookup tables for fli.h and fli.d."
This reverts commit ebc11b68412cdcf2a0e6e2c50df262cfd9b8f481.

I made a mistake in the f16 table. Will fix and recommit.
2023-03-12 22:06:48 -07:00
Chen Zheng
4f0ed16a46 Reland rGf35a09daebd0a90daa536432e62a2476f708150d and rG63854f91d3ee1056796a5ef27753648396cac6ec
[DAGCombiner] handle more store value forwarding

When lowering calls on target like PPC, some stack loads
will be generated for by value parameters. Node CALLSEQ_START
prevents such loads from being combined.

Suggested by @RolandF, this patch removes the unnecessary
loads for the byval parameter by extending ForwardStoreValueToDirectLoad

Reviewed By: nemanjai, RolandF

Differential Revision: https://reviews.llvm.org/D138899
2023-03-12 21:59:18 -04:00
Jun Ma
00eef4f7c3 [SelectionDAG] Fix mismatched truncate when combine BUILD_VECTOR with EXTRACT_SUBVECTOR
Just use correct type for truncation. Fixes PR59625

Differential Revision: https://reviews.llvm.org/D145757
2023-03-13 08:59:52 +08:00
Craig Topper
ebc11b6841 [RISCV] Add separate lookup tables for fli.h and fli.d.
Use separate lookup tables instead of trying to reuse the fli.s
table.

We were missing the 2 denormal cases for fli.h. We also had an issue
where fli.d was only checking 8 bits of the 11 bit exponent.
2023-03-12 11:28:49 -07:00
Craig Topper
858451c50b [RISCV] Add test cases for fli.h and fli.d CodeGen bugs. NFC
We fail to use fli.h for the 2 denormal values.
We use fli.d for some values where the value is larger than a float
can represent due to truncating the exponent to 8 bits without checking
if it fits in 8 bits.
2023-03-12 11:28:49 -07:00
Simon Pilgrim
f759275c1c [AMDGPU] Regenerate sdwa-peephole.ll 2023-03-12 13:50:25 +00:00
Jon Chesterfield
d3dda422bf [amdgpu][nfc] Replace ad hoc LDS frame recalculation with absolute_symbol MD
Post ISel, LDS variables are absolute values. Representing them as
such is simpler than the frame recalculation currently used to build assembler
tables from their addresses.

This is a precursor to lowering dynamic/external LDS accesses from non-kernel
functions.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D144221
2023-03-12 13:47:48 +00:00
Simon Pilgrim
b53ea2b9c5 [DAG] visitAND - fold (and (any_ext V), c) -> (zero_ext (and (trunc V), c)) if profitable.
Try to more aggressively narrow masks of extended values.

This is mainly for cases where the mask is trying to zero out any_extended upper bits, assuming we can zext/trunc the values for free.

This catches a few actual missed folds, as well as helps canonicalize a number of other cases which were being caught in isel etc.

Differential Revision: https://reviews.llvm.org/D145866
2023-03-12 13:25:23 +00:00
Simon Pilgrim
84547ec401 [X86] and-shift.ll - add gnux32 test coverage to ensure the X32 ABI correctly narrows the i64 shifts 2023-03-12 13:11:21 +00:00
Simon Pilgrim
47208f8d34 [X86] matchAddressRecursively - support zext(and(shl(x,c1)),c2) -> shl(zext(and(x, c2 >> c1),c1)
This came about while investigating ways to handle D145468 in a more generic manner, which involves trying harder to fold and(zext(x),c) -> zext(and(x,c))

Alive2: https://alive2.llvm.org/ce/z/7fXtDt (generic fold)

Differential Revision: https://reviews.llvm.org/D145855
2023-03-12 09:49:11 +00:00
Brad Smith
eee590ca4b Revert "[SPARC] Lower BR_CC to BPr on 64-bit target whenever possible"
This reverts commit 6590a372fa3f4582c04b4b179f90a3c728e75025.
2023-03-12 04:20:25 -04:00
Koakuma
6590a372fa [SPARC] Lower BR_CC to BPr on 64-bit target whenever possible
On 64-bit target, when doing i64 BR_CC where one of the comparison operands is a
constant zero, try to fold the compare and BPcc into a BPr instruction.

For all integers, EQ and NE comparison are available, additionally for signed
integers, GT, GE, LT, and LE is also available.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D142461
2023-03-11 17:47:53 -05:00
Koakuma
24e300190a [SPARC] Implement hooks for conditional branch relaxation
Integrate the BranchRelaxation pass to help with relaxing out-of-range
conditional branches.

This is mostly of concern for SPARCv9, which uses conditional branches with
much smaller range than its v8 counterparts.
(Some large autogenerated code, such as the ones generated by TableGen, already
hits this limitation when building in Release)

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D142458
2023-03-11 17:42:09 -05:00
Simon Pilgrim
772aa05452 [X86] Add tests showing the failure to merge SHL/ADD through AND masks into LEA 2023-03-11 18:43:49 +00:00
Simon Pilgrim
fad852efe4 [DAG] combineShiftAnd1ToBitTest - improve support for peeking through truncations
Allows us to handle shift amounts that exceed the original bitwidth
2023-03-11 16:37:47 +00:00
Simon Pilgrim
e554cec49a [DAG] Add test showing combineShiftAnd1ToBitTest failing to peek through a truncation 2023-03-11 14:25:47 +00:00
Luo, Yuanke
91f7153965 [X86] Add unwind for base pointer test case. 2023-03-11 11:41:51 +08:00
Luo, Yuanke
b7021a3bed [X86] Add regcall CC test case for base pointer register. 2023-03-11 11:06:27 +08:00
Pavel Kopyl
507c67d00e [NVPTX] Sync generation of parameter names in a function signature with the function body.
This fixes parameter names mismatch in anonymous functions.

Differential Revision: https://reviews.llvm.org/D144407
2023-03-11 03:40:48 +01:00