This is an archive of the discontinued LLVM Phabricator instance.

[VP][RISCV] Add vp.ctlz/cttz and RISC-V support.
ClosedPublic

Authored by fakepaper56 on Dec 19 2022, 9:24 PM.

Details

Summary

The patch also adds expandVPCTLZ and expandVPCTTZ to expand vp.ctlz/cttz nodes
and the cost model of vp.ctlz/cttz.

Diff Detail

Event Timeline

fakepaper56 created this revision.Dec 19 2022, 9:24 PM
fakepaper56 requested review of this revision.Dec 19 2022, 9:24 PM
craig.topper added inline comments.Dec 20 2022, 4:15 PM
llvm/docs/LangRef.rst
22326

llvm.cttz has 2 arguments. The second is an i1 the indicates the behavior for 0. Do we need that for vectors?

craig.topper added inline comments.Dec 20 2022, 4:20 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
688

Do you intend to have a VP_CTLZ_ZERO_UNDEF and VP_CTTZ_ZERO_UNDEF?

I think I need to implement the is_zero_poison for vp.ctlz/cttz. I missed it because I thought llvm.ctlz and llvm.cttz have same interfaces as llvm.ctpop. I will update the revision soon.

Suppot is_zero_poison for vp.ctlz/cttz.

Fix test fails.

Add missing comment.

Recover some code I should not modify.

fakepaper56 added inline comments.Dec 21 2022, 5:21 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7788

Would it be better to skip Immarg argument in the below Request operands loop?

craig.topper added inline comments.Dec 22 2022, 10:43 AM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7441

The name of this variable is confusing. It's called IsZeroUndef but you select ISD::VP_CTLZ when the bool is true.

Fix confusing code.

This revision is now accepted and ready to land.Jan 3 2023, 8:53 PM
This revision was automatically updated to reflect the committed changes.
llvm/test/CodeGen/RISCV/rvv/cttz-vp.ll