This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombine] Add node level checks for fp-contract and fp-ninf in visitFMULForFMADistributiveCombine().
ClosedPublic

Authored by abinavpp on Aug 5 2021, 3:45 AM.

Diff Detail

Event Timeline

abinavpp created this revision.Aug 5 2021, 3:45 AM
abinavpp requested review of this revision.Aug 5 2021, 3:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2021, 3:45 AM

This patch has no description summary at all :( What's the background to this? Is it related to PR51346 / D74436?

abinavpp added a comment.EditedAug 5 2021, 4:41 AM

This patch has no description summary at all :( What's the background to this? Is it related to PR51346 / D74436?

I'm sorry about that. I believe @arsenm would know the background to this. If I understood the issue raised by @arsenm correctly, we need DAG-combine APIs to not just check for fp-model specific flags, but to have finer SDNode level checks. The new test in AMDGPU/fma.ll is an example I could think of as a motivation for this.

arsenm added a comment.Aug 5 2021, 4:59 PM

This patch has no description summary at all :( What's the background to this? Is it related to PR51346 / D74436?

This is migrating to using the instruction granularity fast math flags instead of the function level fast math attributes, it's unrelated to PR51346

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13031–13033

I swear we had a utility for this already somewhere

llvm/test/CodeGen/AMDGPU/fma.ll
149

Probably should add check lines for the other targets, and add a comment describing the test

abinavpp updated this revision to Diff 365074.Aug 8 2021, 9:46 PM
abinavpp marked an inline comment as done.

Rebased; Addressed review comments.

abinavpp added inline comments.Aug 8 2021, 9:46 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13031–13033

I couldn't find it :(

spatel added inline comments.Aug 9 2021, 9:58 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13073–13077

I think this is the existing code that we're remembering. This seems to be pulling in one more clause for FMA/FMAD - probably want to do that too for this patch?

llvm/test/CodeGen/X86/fma-scalar-combine.ll
567

Not sure if you manually created these check lines or removed the CHECK for a 'ret' line, but it's better to leave that in for easier updating. If you can pre-commit this test with the current (baseline) CHECKs, that would be even better.

abinavpp updated this revision to Diff 365654.Aug 10 2021, 8:58 PM
abinavpp marked an inline comment as done.

Rebased; Addressed review comments.

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
13073–13077

Oh, I thought we were talking about hasNoInfs(), the isContractibleFMUL() is copied from this lambda-expression. I removed the dependence on HasFMAD since it's checking if a target supports FMAD. HasFMA does the same for FMA. I feel isContractibleFMUL() should strictly check for FP-environment and not worry about target specific details.

arsenm accepted this revision.Aug 17 2021, 1:36 PM
This revision is now accepted and ready to land.Aug 17 2021, 1:36 PM

I don't have a commit access. @arsenm, can you commit this on my behalf? Here are my details:
user.name=Abinav Puthan Purayil
user.email=abinav.puthanpurayil@amd.com