[DAGCombiner] Require ninf for division estimation
authorQiu Chaofan <qiucofan@cn.ibm.com>
Sun, 14 Jun 2020 14:58:22 +0000 (22:58 +0800)
committerQiu Chaofan <qiucofan@cn.ibm.com>
Sun, 14 Jun 2020 14:58:22 +0000 (22:58 +0800)
commitf8ef7c99a0199084609ce0e938ea1ff2c3636f09
tree6147258221810bed43b79eb817d4a965d0418f06
parent098e48a6a1555549eed38b9dd1bb5aa0355560ae
[DAGCombiner] Require ninf for division estimation

Current implementation of division estimation isn't correct for some
cases like 1.0/0.0 (result is nan, not expected inf).

And this change exposes a potential infinite loop: we use
isConstOrConstSplatFP in combineRepeatedFPDivisors to look up if the
divisor is some constant. But it doesn't work after legalized on some
platforms. This patch restricts the method to act before LegalDAG.

Reviewed By: spatel

Differential Revision: https://reviews.llvm.org/D80542
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AMDGPU/fdiv.ll
llvm/test/CodeGen/PowerPC/combine-fneg.ll
llvm/test/CodeGen/PowerPC/fdiv.ll
llvm/test/CodeGen/PowerPC/qpx-recipest.ll
llvm/test/CodeGen/PowerPC/recipest.ll
llvm/test/CodeGen/PowerPC/repeated-fp-divisors.ll
llvm/test/CodeGen/PowerPC/vsx-recip-est.ll
llvm/test/CodeGen/X86/fdiv-combine-vec.ll