This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use mask/tail agnostic if tied source is IMPLICIT_DEF regardless of the policy operand.
ClosedPublic

Authored by craig.topper on Oct 6 2022, 1:40 PM.

Details

Summary

If the source is implicit_def, the register allocator won't have
any constraint on what register it picks for the destination. This
doesn't give the user much control of what register is being used.

So in my mind that means the only reason to honor the policy operand
is to control what policy is used in vsetvli to maybe avoid a vtype
change. Given the other optimizations we do on the policy field, I
don't think allowing the user this control is reliable.

Therefore, I think we should use agnostic policies if the source is
undef.

This should give better performance on some CPUs for VP intrinsics where
there is no merge operand and the backend adds IMPLICIT_DEF to the instruction.

Diff Detail

Event Timeline

craig.topper created this revision.Oct 6 2022, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 1:40 PM
craig.topper requested review of this revision.Oct 6 2022, 1:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2022, 1:40 PM
reames added a comment.Oct 6 2022, 3:06 PM

LGTM

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
801–807

This can now be moved up into the vec policy if clause. (It apparently could before, but it's more clear now.)

llvm/test/CodeGen/RISCV/rvv/fixed-vectors-roundeven-vp.ll
14 ↗(On Diff #465861)

Just noting we have same impact here as in https://reviews.llvm.org/D135386#inline-1305623. Non blocking, can keep discussion there for now.

LGTM too - makes sense.

Can I submit this or should I wait for some to click the accept button?

reames accepted this revision.Oct 11 2022, 4:36 PM

LGTM again. In general, please ignore "accept" status if LGTM stated.

This revision is now accepted and ready to land.Oct 11 2022, 4:36 PM

Rebase and move the usesMaskPolicy up

This revision was landed with ongoing or failed builds.Oct 11 2022, 4:43 PM
This revision was automatically updated to reflect the committed changes.