[SDAG] simplify FP binops to undef
authorSanjay Patel <spatel@rotateright.com>
Wed, 4 Mar 2020 15:22:09 +0000 (10:22 -0500)
committerSanjay Patel <spatel@rotateright.com>
Wed, 4 Mar 2020 15:42:16 +0000 (10:42 -0500)
commit29a2b20ab363bcc0b9573e358a5ad12c0eddca86
treefe8afb0b316a2358d320a2149d332145c7c4a506
parentaff6bf4ff81a35a85034b478cccc7015499ce427
[SDAG] simplify FP binops to undef

As discussed in the commit thread for rGa253a2a and D73978, we can do more undef folding for FP ops.
The nnan and ninf fast-math-flags specify that if an operand is the disallowed value, the result is
poison, so we can produce an undef result.

But this doesn't work as expected (the undef operand cases remain) because of a Flags propagation
problem in SelectionDAGBuilder.

I've added DAGCombiner calls to enable these for the other cases because we've shown in other
patches that (because of the limited way that SDAG iterates), it is possible to miss simplifications
like this if they are done only at node creation time.

Several potential follow-ups to expand on this patch are possible.

Differential Revision: https://reviews.llvm.org/D75576
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/test/CodeGen/AArch64/fp-const-fold.ll