This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Don't combine ROTR ((GREV x, 24), 16)->(GREV x, 8) on RV64.
ClosedPublic

Authored by craig.topper on Feb 28 2022, 2:10 PM.

Details

Summary

This miscompile was introduced in D119527.

This was a special pattern for rotate+bswap on RV32. It doesn't
work for RV64 since the rotate needs to be half the bitwidth. The
equivalent pattern for RV64 is ROTR ((GREV x, 56), 32) so match
that instead.

This could be generalized further as noted in the new FIXME.

Diff Detail

Event Timeline

craig.topper created this revision.Feb 28 2022, 2:10 PM
craig.topper requested review of this revision.Feb 28 2022, 2:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2022, 2:10 PM

clang-format

Chenbing.Zheng added inline comments.Mar 1 2022, 1:15 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
7352

Should tests be added for this case?

craig.topper added inline comments.Mar 1 2022, 7:12 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
7352

I added two new tests to rv64zbp.ll bswap_rotr_i64 and bswap_rotl_i64.

Fixup some comments.

Looks great, what about other reviewer's opinions?

Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 6:00 PM
Chenbing.Zheng accepted this revision.Mar 1 2022, 11:25 PM
This revision is now accepted and ready to land.Mar 1 2022, 11:25 PM
This revision was landed with ongoing or failed builds.Mar 2 2022, 9:47 AM
This revision was automatically updated to reflect the committed changes.