[llvm] [RISCV] Check for COPY_TO_REGCLASS in usesAllOnesMask (PR #67037)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 22 04:36:51 PDT 2023
================
@@ -3188,6 +3188,12 @@ static bool usesAllOnesMask(SDValue MaskOp, SDValue GlueOp) {
// Check the instruction defining V0; it needs to be a VMSET pseudo.
SDValue MaskSetter = Glued->getOperand(2);
+ // Sometimes the VMSET is wrapped in a COPY_TO_REGCLASS node, e.g. if the mask
+ // was extracted from a larger register.
----------------
lukel97 wrote:
Yeah, I think this should say "if the mask was extracted from a larger type". The register type is indeed the same (`VRRegClassID`), here's the DAG from the test insertelt_nxv32i8_imm:
```
t28: nxv8i8 = PseudoVSLIDEUP_VI_M1_MASK t41, t30, TargetConstant:i64<3>, Register:nxv8i1 $v0, TargetConstant:i64<4>, TargetConstant:i64<3>, TargetConstant:i64<0>, t37:1
t37: ch,glue = CopyToReg t0, Register:nxv8i1 $v0, t40
t40: nxv8i1 = COPY_TO_REGCLASS t17, TargetConstant:i64<20>
t17: nxv32i1 = PseudoVMSET_M_B32 TargetConstant:i64<-1>, TargetConstant:i64<0>
```
Which is selected to
```
bb.0 (%ir-block.0):
%3:vr = PseudoVMSET_M_B32 -1, 0
%4:vr = COPY %3:vr
$v0 = COPY %4:vr
early-clobber %6:vrnov0 = PseudoVSLIDEUP_VI_M1_MASK %2:vrnov0(tied-def 0), killed %5:vr, 3, $v0, 4, 3, 0
```
The COPY_TO_REGCLASS comes from here:
https://github.com/llvm/llvm-project/blob/c6eb9e2a583a9eccb08ccc56e917691547b26df3/llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp#L2045-L2056
Swapping it out for a plain COPY seems to have no effect, but we still need to peek through it in usesAllOnesMask
https://github.com/llvm/llvm-project/pull/67037
More information about the llvm-commits
mailing list