This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize x > 1 ? x : 1 -> x > 0 ? x : 1
ClosedPublic

Authored by liaolucy on Aug 19 2022, 1:10 AM.

Details

Summary

if x == 1,

x > 1 ? x : 1  return x, which is also 1.
x > 0 ? x : 1  return 1.

Reduce the number of load 1 instructions.

Diff Detail

Event Timeline

liaolucy created this revision.Aug 19 2022, 1:10 AM
liaolucy requested review of this revision.Aug 19 2022, 1:10 AM
liaolucy retitled this revision from Optimize x > 1 ? x : 1 -> x > 0 ? x : 1 to [RISCV] Optimize x > 1 ? x : 1 -> x > 0 ? x : 1.Aug 19 2022, 1:10 AM
liaolucy updated this revision to Diff 453932.Aug 19 2022, 2:09 AM

iFix error , add RHS == TrueV

This revision is now accepted and ready to land.Aug 19 2022, 10:05 AM
craig.topper added inline comments.Aug 19 2022, 10:34 AM
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
4086

Update this comment to x < 1 ? x : 1 -> 0 < x ? x : 1

4086

Oops. I mean 1 < x ? x : 1 -> 0 < x ? x : 1

liaolucy updated this revision to Diff 454301.Aug 21 2022, 5:25 AM

Update comment to 1 < x ? x : 1 -> 0 < x ? x : 1

This revision was landed with ongoing or failed builds.Aug 21 2022, 5:26 AM
This revision was automatically updated to reflect the committed changes.