This is an archive of the discontinued LLVM Phabricator instance.

DAG: Preserve FMF when creating fminnum/fmaxnum
AbandonedPublic

Authored by arsenm on Sep 4 2018, 11:06 AM.

Details

Reviewers
spatel
efriedma
Summary

These should preserve the fast math flags on the initial fcmp.
Without this, the nodes may later be expanded to use an
unnecessary quieting operation.

Diff Detail

Event Timeline

arsenm created this revision.Sep 4 2018, 11:06 AM

Is this just about 'nnan' behavior? If so, can we just use/expand the existing SelectPatternNaNBehavior?

IOW, why is 'nsz' relevant?
Eli raised a question about 'nsz' on fcmp:
https://bugs.llvm.org/show_bug.cgi?id=38086

Does the motivation for this patch make any of the proposed fixes more or less appealing?

Regardless to any answers to the above, I think we should split this into separate IR/DAG patches with tests for each side.

Is this just about 'nnan' behavior? If so, can we just use/expand the existing SelectPatternNaNBehavior?

IOW, why is 'nsz' relevant?
Eli raised a question about 'nsz' on fcmp:
https://bugs.llvm.org/show_bug.cgi?id=38086

Does the motivation for this patch make any of the proposed fixes more or less appealing?

Regardless to any answers to the above, I think we should split this into separate IR/DAG patches with tests for each side.

The combine to form minnum/maxnum from cmp/select depends on nsz. The DAG version of the combine checks the global NSZ flag, but I think the direct-from-ir version is broken. I've never really liked the matching here in SelectionDAGBuilder, but haven't looked into what regresses if I try just ripping out the IR matching.

There's also another bug from doing this I've noticed, where the dead nodes are left which breaks hasOneUse optimizations

arsenm added inline comments.
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
1088–1091

I forgot about this problem. I don't understand why it was trying to strip these flags in the first place, but it will always do it

arsenm updated this revision to Diff 164095.Sep 5 2018, 11:58 AM

Split out DAG part

aemerson added inline comments.
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
1088–1091

Maybe this is related, we've seen on D51145 that if the FPMathOperator doesn't actually have any FP flags (like insert/extractelements) then the incoming flags result in stripping.

kpn added a subscriber: kpn.Sep 6 2018, 10:17 AM
arsenm abandoned this revision.Apr 5 2020, 7:40 AM