21 Commits

Author SHA1 Message Date
Luke Lau
286a366d05
[RISCV] Remove vmv.s.x and vmv.x.s lmul pseudo variants (#71501)
vmv.s.x and vmv.x.s ignore LMUL, so we can replace the PseudoVMV_S_X_MX
and
PseudoVMV_X_S_MX with just one pseudo each. These pseudos use the VR
register
class (just like the actual instruction), so we now only have TableGen
patterns for vectors of LMUL <= 1.
We now rely on the existing combines that shrink LMUL down to 1 for
vmv_s_x_vl (and vfmv_s_f_vl). We could look into removing these combines
later and just inserting the nodes with the correct type in a later
patch.

The test diff is due to the fact that a PseudoVMV_S_X/PsuedoVMV_X_S no
longer
carries any information about LMUL, so if it's the only vector pseudo
instruction in a block then it now defaults to LMUL=1.
2024-01-16 13:36:24 +07:00
Craig Topper
4dd5d96797
[RISCV] Don't call use_nodbg_operands for physical registers in RISCVOptWInstrs hasAllNBitUsers. (#77032)
The ADDIW in the new test case was incorrectly removed due to
incorrectly following the x10 register from the return value back to the
argument. This is due to use_nodbg_operands returning every instruction
that uses a physical register regardless of the data flow.
2024-01-05 09:22:54 -08:00
Craig Topper
4162a9bca4 [RISCV] Cleanup pass initialization.
Remove redundant initializations from pass constructors that were
already being initialized by LLVMInitializeRISCVTarget().
2023-12-07 18:21:38 -08:00
Craig Topper
b310932f87
[RISCV] Add vmv.x.s to RISCVOptWInstrs. (#74519)
This instruction produces a 32-bit sign extended value if the SEW is less than or
equal to 32.
2023-12-06 17:06:56 -08:00
Craig Topper
55f91bfe50 [RISCV] Ignore debug instructions in hasAllNBitUsers in RISCVOptWInstrs. 2023-12-03 21:27:50 -08:00
Craig Topper
1c033aaac9 [RISCV] Add IsSignExtendingOpW to AMO*_W instructions. (#72349) 2023-11-15 09:39:31 -08:00
Craig Topper
c14602b318 [RISCV] Add PseudoCCADDIW/SLLW/SRLW/SRAW/SLLIW/SRLIW/SRAIW to RISCVOptWInstrs.
These can be treated simlarly to PseudoCCADDW/SUBW.
2023-11-13 22:41:52 -08:00
Craig Topper
c4649d05cf [RISCV] Teach RISCVOptWInstrs that 'bset x0, 30-0' satisfies isSignExtendingOpW.
Constant materialization can use bset x0, 11 to create 2048.
2023-11-01 12:29:37 -07:00
Wang Pengcheng
a316f14fdd
[RISCV][NFC] Move getRVVMCOpcode to RISCVInstrInfo (#70637)
To simplify more code.
2023-10-30 19:03:04 +08:00
Craig Topper
e40b2d40a4
[RISCV] Use range-based for loops in RISCVOptWInstrs. NFC (#69647) 2023-10-20 09:51:45 -07:00
Philip Reames
8624075105
[RISCV] Strip W suffix from ADDIW (#68425)
The motivation of this change is simply to reduce test duplication. As
can be seen in the (massive) test delta, we have many tests whose output
differ only due to the use of addi on rv32 vs addiw on rv64 when the
high bits are don't care.

As an aside, we don't need to worry about the non-zero immediate
restriction on the compressed variants because we're not directly
forming the compressed variants. If we happen to get a zero immediate
for the ADDI, then either a later optimization will strip the useless
instruction or the encoder is responsible for not compressing the
instruction.
2023-10-06 10:28:01 -07:00
Luke Lau
e577e7025d
[RISCV] Move vector pseudo hasAllNBitUsers switch into RISCVInstrInfo. NFC (#67593)
The handling for vector pseudos in hasAllNBitUsers is duplicated across
RISCVISelDAGToDAG and RISCVOptWInstrs. This deduplicates it between the
two,
with the common denominator between the two call sites being the opcode
and
SEW: We need to handle extracting these separately since one operates at
the
SelectionDAG level and the other at the MachineInstr level.
2023-10-03 12:24:11 +01:00
Craig Topper
e6b2525daf [RISCV] Fix -Wsign-compare warning. NFC 2023-09-27 13:41:06 -07:00
Luke Lau
5ffbdd9ed5 [RISCV] Handle .vx pseudos in hasAllNBitUsers (#67419)
Vector pseudos with scalar operands only use the lower SEW bits (or less in the
case of shifts and clips). This patch accounts for this in hasAllNBitUsers for
both SDNodes in RISCVISelDAGToDAG. We also need to handle this in
RISCVOptWInstrs otherwise we introduce slliw instructions that are less
compressible than their original slli counterpart.

This is a reland of aff6ffc8760b99cc3d66dd6e251a4f90040c0ab9 with the
refactoring omitted.
2023-09-27 19:53:50 +01:00
Philip Reames
487dd5f1e3 Revert "[RISCV] Handle .vx pseudos in hasAllNBitUsers (#67419)"
This reverts commit aff6ffc8760b99cc3d66dd6e251a4f90040c0ab9.  Version landed differs from version reviewed in (stylistic) manner worthy of separate review.
2023-09-27 11:24:49 -07:00
Luke Lau
aff6ffc876
[RISCV] Handle .vx pseudos in hasAllNBitUsers (#67419)
Vector pseudos with scalar operands only use the lower SEW bits (or less
in the
case of shifts and clips). This patch accounts for this in
hasAllNBitUsers for
both SDNodes in RISCVISelDAGToDAG. We also need to handle this in
RISCVOptWInstrs otherwise we introduce slliw instructions that are less
compressible than their original slli counterpart.
2023-09-27 18:12:29 +01:00
Luke Lau
733e3c60a4
[RISCV] Update comment on -w stripping pass. NFC (#67415)
It looks like we only strip the -w suffix from addw and not addiw
(because c.addiw and c.addi have the same register encoding), but the
comment in the header seems to have it the other way round.
2023-09-26 16:48:34 +01:00
Craig Topper
1f395115da [RISCV] Add Zicond instructions to RISCVOptWInstrs like XVentanaCondOps. 2023-08-23 16:57:16 -07:00
Elliot Goodrich
4d0f1e3282 [llvm] Remove SmallSet from MachineInstr.h
`MachineInstr.h` is a commonly included file and this includes
`llvm/ADT/SmallSet.h` for one function `getUsedDebugRegs()`, which is
used only in one place.

According to `ClangBuildAnalyzer` (run solely on building LLVM, no other
projects) the second most expensive template to instantiate is the
`SmallSet::insert` method used in the `inline` implementation in
`getUsedDebugRegs()`:

```
**** Templates that took longest to instantiate:
554239 ms: std::unordered_map<int, int> (2826 times, avg 196 ms)
521187 ms: llvm::SmallSet<llvm::Register, 4>::insert (930 times, avg 560
       ms)
...
```

By removing this method and putting its implementation in the one call
site we greatly reduce the template instantiation time and reduce the
number of includes.

When copying the implementation, I removed a check on `MO.getReg()` as
this is checked within `MO.isVirtual()`.

Differential Revision: https://reviews.llvm.org/D157720
2023-08-12 18:15:27 +01:00
Craig Topper
3d7fa6dc7c [RISCV] Move allWUsers from RISCVInstrInfo to RISCVOptWInstrs.
It was only in RISCVInstrInfo because it was used by 2 passes, but those
passes have been merged in D147173.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D147174
2023-03-29 15:13:09 -07:00
Craig Topper
4c10a6122e [RISCV] Merge SExtWRemoval and StripWSuffix into a single pass.
These run together in the pipeline and are the only users of
TII.hasAllWUsers. Merging them will allow us to move hasAllWUsers
back from TII.

Reviewed By: asb

Differential Revision: https://reviews.llvm.org/D147173
2023-03-29 15:00:47 -07:00