This is an archive of the discontinued LLVM Phabricator instance.

use riscv vsetvl to tailfolding
Needs ReviewPublic

Authored by lizhengxian.123 on Oct 24 2022, 2:08 AM.

Details

Summary

we found that llvm now doesn't support riscv vsetvl instruction to tail folding. we create a new cmdline option:

--prefer-predicate-over-epilogue=vlen-else-scalar-epilogue

which can do tali folding with riscv vsetvl instruction.

Co-authored-by: lidawei lidawei.1226@bytedance.com

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2022, 2:08 AM
lizhengxian.123 requested review of this revision.Oct 24 2022, 2:08 AM
kito-cheng retitled this revision from use riscv vsetvl to tailfolding Co-authored-by: lidawei lidawei.1226@bytedance.com to use riscv vsetvl to tailfolding.Oct 24 2022, 2:26 AM
kito-cheng edited the summary of this revision. (Show Details)

You don't have to create a new differential, you could just upload your new patch in D136583. For now, let's discuss in this differential.

I have got what you want to do, but I think you can refer to Vector Predication and works in llvm-epi.

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
115

It's target-dependent.
I would suggest that we add target hooks in TargetTransformInfo.

9813

Ditto.

9850

Ditto.

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
238

Ditto.

MTC added a subscriber: MTC.Oct 24 2022, 2:56 AM
reames added a subscriber: simoll.Oct 24 2022, 7:56 AM

FYI, this isn't going to be accepted in the current form. We don't allow the use of target specific intrinsics directly from the generic IR optimizer.

If you're interested in this approach, I recommend you take a look at the work that BSC has done using the VP intrinsics. I think that's the closest we have to something which is likely to eventually make it upstream. If you wanted to spend time working on that, you should talk to @simoll, and come to the next RISC-V sync up call or VP sync up. (The VP syncs have been getting canceled, so the general RISC-V sync is probably a better idea.) I'd also be happy to jump on a call and talk through this topic.

kito-cheng resigned from this revision.Apr 25 2023, 8:54 PM

D99750 should be better approach for that