This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Handle EltType > XLEN case in VMV_V_X_VL to VMV_S_X_VL fold
ClosedPublic

Authored by reames on Aug 30 2023, 2:31 PM.

Details

Summary

I'd guarded this case in D158874 to avoid regressions, and decided to go investigate what was going on. The solution turns out to be a generic splat matching extension to handle INSERT_SUBVECTOR. In theory, we could see these from other sources as well, but for some reason we only seem to see the i64 extract on rv32 case in practice. Not sure why that is to be honest.

Diff Detail

Event Timeline

reames created this revision.Aug 30 2023, 2:31 PM
reames requested review of this revision.Aug 30 2023, 2:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2023, 2:31 PM
luke added inline comments.Aug 31 2023, 4:09 AM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2964

Are we getting multiple nested insert_subvectors? If their vector operands are undef shouldn't they be getting combined away? I found this combine in DAGCombiner.cpp:

// Eliminate an intermediate insert into an undef vector:
// insert_subvector undef, (insert_subvector undef, X, 0), N2 -->
// insert_subvector undef, X, N2
if (N0.isUndef() && N1.getOpcode() == ISD::INSERT_SUBVECTOR &&
    N1.getOperand(0).isUndef() && isNullConstant(N1.getOperand(2)))
  return DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(N), VT, N0,
                     N1.getOperand(1), N2);
reames added inline comments.Aug 31 2023, 9:59 AM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
2964

Not that I saw, I can remove the loop if desired. This is just replacing the "while" with an "if".

This revision is now accepted and ready to land.Sep 22 2023, 11:43 AM
This revision was landed with ongoing or failed builds.Sep 22 2023, 1:44 PM
This revision was automatically updated to reflect the committed changes.