This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add a test showing an incorrect VSETVLI insertion
ClosedPublic

Authored by frasercrmck on Jan 31 2022, 10:03 AM.

Details

Summary

This test shows a loop, whose preheader uses a SEW=64, LMUL=1 vector
operation. The loop body starts off with another SEW=64, LMUL=1 VADD
vector operation, before switching to a SEW=32, LMUL=1/2 vector store
instruction.

We can see that the VSETVLI insertion pass omits a VSETVLI before the
VADD (thinking it inherits its configuration from the preheader) but
does place a SEW=32, LMUL=1/2 VSETVLI before the store. This results in
a miscompilation as when the loop comes back around, the VADD is
incorrectly configured with SEW=32, LMUL=1/2.

It appears to be a bad load/store optimization, as replacing the vector
store with an SEW=32, LMUL=1/2 VADD does correctly insert a VSETVLI. The
issue is therefore possibly arising from canSkipVSETVLIForLoadStore.

Diff Detail

Event Timeline

frasercrmck created this revision.Jan 31 2022, 10:03 AM
frasercrmck requested review of this revision.Jan 31 2022, 10:03 AM

Sadly found this on the eve of LLVM 14's branch. I've run out of time to fix it today but I'll take a look tomorrow.

  • add a comment explaining the issue
frasercrmck edited the summary of this revision. (Show Details)Feb 1 2022, 2:28 AM

improve test FIXME

This revision was not accepted when it landed; it landed in state Needs Review.Feb 1 2022, 2:31 AM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.

I landed this test without it formally being accepted to reduce dependencies between myself and @craig.topper.