[ConstantFold] fold fsub -0.0, undef to undef rather than NaN
authorSanjay Patel <spatel@rotateright.com>
Fri, 21 Feb 2020 12:58:36 +0000 (07:58 -0500)
committerSanjay Patel <spatel@rotateright.com>
Fri, 21 Feb 2020 13:03:19 +0000 (08:03 -0500)
commitd799190851fdd94800428ba335f864ce5fd8135b
tree5de0d299a4f8e0b8d8bce0b2c3b07b5c1d86abf3
parent99b03c1c18de3e4228e31ef04d38f2d530d335be
[ConstantFold] fold fsub -0.0, undef to undef rather than NaN

A question about this behavior came up on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2020-February/139003.html
...and as part of backend improvements in D73978, but this is an IR
change first because we already have fairly thorough tests in place
here.

We decided not to implement a more general change that would have
folded any FP binop with nearly arbitrary constant + undef operand
to undef because that is not theoretically correct (even if it is
practically correct).

Differential Revision: https://reviews.llvm.org/D74713
llvm/lib/IR/ConstantFold.cpp
llvm/test/Analysis/ConstantFolding/fp-undef.ll