This is an archive of the discontinued LLVM Phabricator instance.

[X86] Avoid usage constant -1 for fminimum/fmaximum lowering
ClosedPublic

Authored by skatkov on May 3 2023, 9:13 PM.

Details

Summary

Instead of equality comparison of value to preferred zero we can check just
the sign of value and if sign is set we should put this value as second operand for minimum
and first operand for maximum.
In this case FMIN/FMAX will choose the right result for 0.f and -0.f comparison.

This allows us:

  1. avoid loading of big 64-bit constant for fminimum.
  2. for double on non-64-nit platform we need to check only high part of value.
  3. test against zero to check sign takes less size of instruction

Additionally, if we know that any of value is guaranteed to be non-zero
we should not care about 0.f and -0.f comparison.

Diff Detail

Event Timeline

skatkov created this revision.May 3 2023, 9:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2023, 9:13 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
skatkov requested review of this revision.May 3 2023, 9:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2023, 9:13 PM
e-kud accepted this revision.May 4 2023, 7:31 PM

LGTM. Thank you!

This revision is now accepted and ready to land.May 4 2023, 7:31 PM
This revision was landed with ongoing or failed builds.May 5 2023, 2:24 AM
This revision was automatically updated to reflect the committed changes.