Open dtcxzyw opened 3 months ago
We really need a version of ISD::FMINNUM/FMAXNUM that always respect the 0 sign. This would also be a lot easier if we just fix the definition of minnum/maxnum to have the IEEE snan behavior.
Also, can we just get rid of this IR pattern matching in SelectionDAGBuilder? We already have to repeat the same matching on the DAG node, and it's really difficult to test when the DAG builder has hidden optimizations in it
Reproducer: https://godbolt.org/z/sqYqK8vd9
When
%1
is -0.0, the former returns +0.0 while the latter returns -0.0.SelectionDAGBuilder::visitSelect
incorrectly refined the select (always returns +0.0 when the input is -0.0) intoISD::FMINNUM
(returns either 0.0 or -0.0). Related code: https://github.com/llvm/llvm-project/blob/a4a436672a2c179274e07aeb68e9acd6f483a653/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp#L3718-L3754cc @topperc @arsenm