This is an archive of the discontinued LLVM Phabricator instance.

[SVE] Fix SVEDup0 matching -0.0f
ClosedPublic

Authored by steplong on Aug 29 2022, 12:50 PM.

Details

Summary

Because of D128669, CPY is being used to zero active lanes even in the case of -0.0f. This patch checks for floating point positive zero. That way SVEDup0 won't match -0.0f.

Fixes https://github.com/llvm/llvm-project/issues/57428

Diff Detail

Event Timeline

steplong created this revision.Aug 29 2022, 12:50 PM
Herald added a project: Restricted Project. · View Herald Transcript
steplong requested review of this revision.Aug 29 2022, 12:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 12:50 PM
steplong edited the summary of this revision. (Show Details)Aug 29 2022, 12:55 PM

I'm not sure how to test this. Also how do I reference the issue I created on Github: https://github.com/llvm/llvm-project/issues/57428?

llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
185–186

Does it make sense to check for isNegative here also?

Also how do I reference the issue I created on Github

To refer to the issue, just put "Fixes https://github.com/llvm/llvm-project/issues/57428" in the commit message. GitHub will cross-link that automatically.

I'm not sure how to test this.

Backend regression tests generally go into llvm/test/CodeGen/AArch64. You can probably just add a few lines to the existing test llvm/test/CodeGen/AArch64/sve-vselect-imm.ll to cover this case.

Matt added a subscriber: Matt.Aug 29 2022, 4:33 PM
paulwalker-arm added inline comments.Aug 30 2022, 3:10 AM
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
185–186

Yes please.

203–204

It looks like we can wrap these into a single isNullFPConstant() call?

steplong updated this revision to Diff 456666.Aug 30 2022, 7:35 AM
  • Add tests for SVEDup0 case
  • Change to isNullFPConstant and isNullConstant
paulwalker-arm accepted this revision.Aug 30 2022, 7:43 AM
This revision is now accepted and ready to land.Aug 30 2022, 7:43 AM
steplong edited the summary of this revision. (Show Details)Aug 30 2022, 8:55 AM
This revision was automatically updated to reflect the committed changes.
Allen added a subscriber: Allen.Apr 25 2023, 6:06 AM
Allen added inline comments.
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
187

sorry, I have a question: can we match the -0.0 if the option -ffast-math is added in command ?

paulwalker-arm added inline comments.Apr 27 2023, 5:02 AM
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
187

That feels a little dangerous to me. I think such a canonicalisation would be better done at the DAG or perhaps even the IR level. For instruction selection it seems safer to be explicit.

Allen added inline comments.Apr 27 2023, 8:43 PM
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
187

Thanks for your information.