This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][GlobalISel] Select scalar G_FMAXIMUM + G_FMINIMUM
ClosedPublic

Authored by paquette on Dec 8 2021, 12:44 PM.

Details

Summary

Import the patterns via tablegen.

Putting this in AArch64InstrGISel.td assuming it wasn't in SelectionDAGCompat.td for a good reason.

Diff Detail

Event Timeline

paquette created this revision.Dec 8 2021, 12:44 PM
paquette requested review of this revision.Dec 8 2021, 12:44 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 8 2021, 12:44 PM
jroelofs added inline comments.Dec 8 2021, 1:03 PM
llvm/test/CodeGen/AArch64/GlobalISel/select-fmaximum.mir
44

Am I reading the ARM/GISel docs correctly that G_FMAXIMUM corresponds to the FMAX instructions, G_FMAXNUM_IEEE corresponds to FMAXNM, and that there isn't direct support on ARMv8 for G_FMAXNUM?

A quick look at the SelectionDAG code suggests the opposite re: FMAXNM vs FMAXNM_IEEE though... so there's either a bug in my understanding, or SDAG got it wrong?

paquette added inline comments.Dec 9 2021, 9:06 PM
llvm/test/CodeGen/AArch64/GlobalISel/select-fmaximum.mir
44

Apparently AArch64InstrInfo.td says...

defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", fmaxnum>;
defm FMAX   : TwoOperandFPData<0b0100, "fmax", fmaximum>;

So I'd assume

G_FMAXNUM -> fmaxnm
G_FMAXIMUM -> fmax

Maybe I'm wrong though?

fhahn added a subscriber: fhahn.May 6 2022, 6:04 AM

reverse ping :)

Herald added a project: Restricted Project. · View Herald TranscriptMay 6 2022, 6:04 AM

Second reverse ping.

@aemerson wdyt about Jon's comment on the test?

@aemerson wdyt about Jon's comment on the test?

I haven't a clue what's going on with signaling NaNs and llvm. I think the safest thing is to emulate existing codegen behavior and maybe someone else, @eli.friedman? might be able to explain.

As far as I can tell, the AArch64 fmaxnm actually corresponds to ISD::FMAXNUM_IEEE. I wouldn't be surprised if SelectionDAG is wrong; rG687ec75d was implemented well after the AArch64 backend was written. Granted, SNaNs are rarely used, especially with floating-point exceptions disabled, so maybe nobody noticed.

Generic part LGTM, I have no idea about the AArch64 instruction behavior

llvm/lib/Target/AArch64/AArch64InstrGISel.td
244–245 ↗(On Diff #392884)

This is obvious, LGTM

arsenm added inline comments.Jul 19 2022, 6:43 AM
llvm/lib/Target/AArch64/AArch64InstrGISel.td
244–245 ↗(On Diff #392884)

Actually this doesn't LGTM. This belongs in generic code

aemerson accepted this revision.Jul 25 2022, 11:21 PM

Since the correctness of FMAXIMUM/FMINIMUM aren't in question, this LGTM assuming we move it to SelectionDAGCompat.td instead.

This revision is now accepted and ready to land.Jul 25 2022, 11:21 PM
paquette updated this revision to Diff 447763.Jul 26 2022, 10:58 AM

Import the pattern everywhere + rebase test before pushing.

This revision was landed with ongoing or failed builds.Jul 26 2022, 10:59 AM
This revision was automatically updated to reflect the committed changes.