This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Don't emit fractional VIDs with negative steps
ClosedPublic

Authored by frasercrmck on Apr 14 2022, 7:51 AM.

Details

Summary

We can't shift-right negative numbers to divide them, so avoid emitting
such sequences. Use negative numerators as a proxy for this situation, since
the indices are always non-negative.

An alternative strategy could be to add a compiler flag to emit division
instructions, which would at least allow us to test the VID sequence
matching itself.

Diff Detail

Event Timeline

frasercrmck created this revision.Apr 14 2022, 7:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 14 2022, 7:52 AM
frasercrmck requested review of this revision.Apr 14 2022, 7:52 AM
craig.topper added inline comments.Apr 18 2022, 1:24 PM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll
642

This code seemed to do the right thing if I did the math correctly

-5 - (vid / 4)

frasercrmck added inline comments.Apr 19 2022, 1:44 AM
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-int-buildvec.ll
642

Yes I think you're right, thanks. The issue is that I got the wrong check for positivity, as there's a case where we make the effective numerator positive and StepNumerator is left in the old negative state. I think we should be checking SplatStepVal instead.

fix check for positivity

This revision is now accepted and ready to land.Apr 20 2022, 9:22 PM
frasercrmck edited the summary of this revision. (Show Details)Apr 20 2022, 11:04 PM
This revision was landed with ongoing or failed builds.Apr 20 2022, 11:12 PM
This revision was automatically updated to reflect the committed changes.