This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use positive 0.0 for the neutral element in fadd reductions if nsz is present.
ClosedPublic

Authored by craig.topper on Dec 17 2021, 3:37 PM.

Details

Summary

-0.0 requires a constant pool. +0.0 can be made with vmv.v.x x0.

Not doing this in getNeutralElement for fear of changing other targets.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 17 2021, 3:37 PM
craig.topper requested review of this revision.Dec 17 2021, 3:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2021, 3:37 PM
Herald added a subscriber: MaskRay. · View Herald Transcript
craig.topper retitled this revision from [RISCV] Use positive 0.0 for the neutral element in reductions if nsz is present. to [RISCV] Use positive 0.0 for the neutral element in fadd reductions if nsz is present..Dec 17 2021, 3:39 PM
rogfer01 accepted this revision.Dec 22 2021, 11:32 PM

LGTM.

Though perhaps we can improve the generation of -0.0 in another patch.

Something like this (similarly for f64)

fmv.w.x	fa5, x0
fsgnjn.s fa5, fa5, fa5

I think it should work and we avoid the constant pool (at expense of an extra instruction).

This revision is now accepted and ready to land.Dec 22 2021, 11:32 PM
This revision was landed with ongoing or failed builds.Dec 23 2021, 8:38 AM
This revision was automatically updated to reflect the committed changes.