This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Fold (select setcc, setcc, setcc) into and/or instructions
ClosedPublic

Authored by dtcxzyw on May 10 2023, 11:32 AM.

Details

Summary

This patch folds (select setcc, setcc, setcc) into and/or instructions when truev/falsev is equal to or the inverse of condv.

(select x, x, y) -> x | y https://alive2.llvm.org/ce/z/36Ud3Z
(select !x, x, y) -> x & y https://alive2.llvm.org/ce/z/mYYoGF
(select x, y, x) -> x & y https://alive2.llvm.org/ce/z/MAZ--X
(select !x, y, x) -> x | y https://alive2.llvm.org/ce/z/ct7By5

It is the follow-up improvement of D150177, which optimizes the code of signed truncation check patterns without Zbb.

Diff Detail

Event Timeline

dtcxzyw created this revision.May 10 2023, 11:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2023, 11:32 AM
dtcxzyw requested review of this revision.May 10 2023, 11:32 AM
craig.topper added inline comments.May 10 2023, 12:07 PM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5354

Can we return std::optional<bool> similar to isImpliedCondition from lib/Analysis/ValueTracking. I think this is very similar to that.

dtcxzyw updated this revision to Diff 521225.May 11 2023, 1:32 AM

fix comment and rebase

dtcxzyw marked an inline comment as done.May 11 2023, 1:35 AM
dtcxzyw added inline comments.
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
5354

Thank you for your suggestion.

dtcxzyw marked an inline comment as done.May 11 2023, 1:36 AM
This revision is now accepted and ready to land.May 11 2023, 11:39 AM