[Bug target/126411] RISC-V rv64gcv: wrong code at -O0 with simple shuffle

souradiptodas6 at gmail dot com via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126411

--- Comment #5 from Souradipto Das <souradiptodas6 at gmail dot com> ---
(In reply to Raphael M Zinsly from comment #3)
> (In reply to Souradipto Das from comment #2)
> > Created attachment 65147 [details]
> > [PATCH] RISC-V: Reject non-monotonic shuffle masks in slide patterns
> > 
> > Hi, I added checks so that intermediate elements conform to the expected
> > monotonic slide segments. I wasn't able to get a clean make check run
> > locally due to DejaGNU board-file configuration issues on my end (unrelated
> > to the patch itself) but i was able to verify that the patch holds its
> > effectiveness on this bug
> 
> This seems to work but I think you could do that without the loop as we
> already look for a monotonic sequence later, you could explicitly check if
> the beginning and end of the sequence corresponds to OP0 and OP1
> respectively (vlen - slideup_cnt and 2 * vlen - 1 - slideup_cnt). The
> current code assumes that but this is not guaranteed as this testcased
> caught. This could be checked in the same place as we look at the
> slideup_cnt positions.
> If you go this route you should also check for only one pivot by adding
> need_slideup_p in the second pivot check to be safe.

Thank you so much for the suggestions, I have updated the patch and re-verified
against the original reproducer with this revision: unpatched still reproduces
the bug (checksum 0x00 / abort) from the original testcase, patched gives the
correct result (checksum 0x46 / clean exit).

I'm running a fuller regression pass (full rvv.exp before/after diff via
qemu-user, plus a broader riscv.exp/vect.exp sweep) and will follow up with
those results too.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.