This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add patterns for checking isnan
ClosedPublic

Authored by lenary on Apr 27 2020, 2:35 AM.

Details

Summary

This patch addresses some weird assembly sequences we were seeing during
comparing floats. In particular, comparing a float to itself tells you whether
it is NaN or not, which we were doing correctly, but with an extra unneeded
and instruction.

This patch specialises the existing patterns to remove the and instruction
when both their operands are the same.

Diff Detail

Event Timeline

lenary created this revision.Apr 27 2020, 2:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2020, 2:35 AM
asb added inline comments.Apr 30 2020, 2:22 AM
llvm/lib/Target/RISCV/RISCVInstrInfoD.td
316

I think this pattern and the matching one in RISCVInstrInfoF.td is left untested?

lenary marked an inline comment as done.Apr 30 2020, 2:32 AM
lenary added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoD.td
316

This pattern is what is tested by fcmp uno {float,double} %0, 0.000000e+00. The sltiu is shown in the assembly output as seqz.

asb accepted this revision.Apr 30 2020, 3:30 AM

LGTM, thanks!

llvm/lib/Target/RISCV/RISCVInstrInfoD.td
316

Doh - thanks!

This revision is now accepted and ready to land.Apr 30 2020, 3:30 AM
lenary updated this revision to Diff 261642.May 2 2020, 6:52 AM

Updates based on test changes (to use hardfloat ABIs).

This revision was automatically updated to reflect the committed changes.