This is an archive of the discontinued LLVM Phabricator instance.

[GISel] Add new combines for G_FMINNUM/MAXNUM and G_FMINIMUM/MAXIMUM
ClosedPublic

Authored by mkitzan on May 17 2022, 10:58 AM.

Details

Summary

I noticed https://reviews.llvm.org/D87415 added SDAG combines to fold FMIN/MAX instrs with NaNs.

The patch implements the same NaN combines for GISel GMIR FMIN/MAX opcodes:
G_FMINNUM(X, NaN) -> X
G_FMAXNUM(X, NaN) -> X
G_FMINIMUM(X, NaN) -> NaN
G_FMAXIMUM(X, NaN) -> NaN

The patch adds AArch64 tests for these combines as well.

Diff Detail

Event Timeline

mkitzan created this revision.May 17 2022, 10:58 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2022, 10:58 AM
mkitzan requested review of this revision.May 17 2022, 10:58 AM
arsenm added inline comments.May 17 2022, 12:58 PM
llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
109

Spelling Propagate throughout the patch

foad added inline comments.May 18 2022, 4:04 AM
llvm/include/llvm/Target/GlobalISel/Combine.td
894

You should be able to use replaceSingleDefInstWithOperand instead of defining your own apply function. See the select_constant_cmp combine for an example of this.

mkitzan updated this revision to Diff 430468.May 18 2022, 11:47 AM

Updates:

  • Fixed spelling of propagate
  • Exchanged my custom apply function for replaceSingleDefInstWithOperand
arsenm accepted this revision.May 18 2022, 11:58 AM
This revision is now accepted and ready to land.May 18 2022, 11:58 AM
This revision was landed with ongoing or failed builds.May 18 2022, 12:22 PM
This revision was automatically updated to reflect the committed changes.

Thanks for reviews and feedback @arsenm and @foad

foad added inline comments.May 19 2022, 12:54 AM
llvm/include/llvm/Target/GlobalISel/Combine.td
894

There is a standard unsigned_matchinfo you can use instead of defining your own.

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
5608

This could be llvm_unreachable