This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Move vmv_s_x and vfmv_s_f special casing to DAG combine
ClosedPublic

Authored by reames on Aug 25 2023, 8:31 AM.

Details

Summary

We'd discussed this in the original set of patches months ago, but decided against it. I think we should reverse ourselves here as the code is significantly more readable, and we do pick up cases we'd missed by not calling the appropriate helper routine.

Diff Detail

Event Timeline

reames created this revision.Aug 25 2023, 8:31 AM
reames requested review of this revision.Aug 25 2023, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2023, 8:31 AM
luke added inline comments.Aug 25 2023, 8:39 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
14001

So if I'm understanding correctly, the reason for the extra test cases being picked up is because the combine above to shrink LMUL down to 1 runs first, and then this combine is run because now LMUL=1.
Can we get rid of VT.bitsLE(getLMUL1VT(VT)) condition and comment here? Since the above combine will always run first in this case.

reames added inline comments.Aug 25 2023, 10:39 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
14001

Er, I think you misunderstood. These are independent transforms. The test change comes from the fact we're generating a whole bunch of vmv_s_x/f directly without going through the lowerScalarInsert cover function. To my knowledge, there's no order of transform issue here.

craig.topper accepted this revision.Aug 29 2023, 2:42 PM

LGTM with that comment addressed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp
14000

!isNullConstant(Scalar) -> !Const->isZero()

This revision is now accepted and ready to land.Aug 29 2023, 2:42 PM
This revision was landed with ongoing or failed builds.Aug 30 2023, 12:05 PM
This revision was automatically updated to reflect the committed changes.