This is an archive of the discontinued LLVM Phabricator instance.

[RISCV][Backend] Zext flag conversion in RISC-V Backend
Needs ReviewPublic

Authored by karouzakisp on Jul 27 2023, 8:49 AM.

Details

Reviewers
craig.topper
Summary

Added zext flag named was_sext in IR
RISCVCodeGenPrepare does a conversion that converts all the
zext instructions with the flag back to sext.

Diff Detail

Event Timeline

karouzakisp created this revision.Jul 27 2023, 8:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 8:49 AM
karouzakisp requested review of this revision.Jul 27 2023, 8:49 AM
karouzakisp removed a project: Restricted Project.Jul 27 2023, 8:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 8:51 AM

Need tests and real patch title.

llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
89

"an non" -> "a non"

karouzakisp retitled this revision from [llvm][RISCV][Backend] to Zext flag conversion in RISC-V Backend.Jul 27 2023, 9:49 AM

Should still keep [RISCV] at the beginning of the title. Those tags are helpful for filtering emails from llvm-commits.

karouzakisp retitled this revision from Zext flag conversion in RISC-V Backend to [RISCV][Backend] Zext flag conversion in RISC-V Backend.

Added -U999999 in
git show
to make possible the reviewing via the web interface.

Added simple tests.

Fixed the test that failed to convert the zext(value) to sext(value) whenever the value was assumed to be non negative by llvm.assume

craig.topper added inline comments.Sep 1 2023, 3:39 PM
llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp
89

Could we have InstCombine call isKnownNonNegative during visitZExt and set the flag if the input is non negative? Then we only need the code here that checks the flag.

Removed IsKnownNonNegative from RISCVCodeGen and added in InstCombine::visitZExt