[InstCombine] Use +0.0 instead of -0.0 as the FP identity for some folds
authorDavid Sherwood <david.sherwood@arm.com>
Tue, 31 May 2022 14:54:49 +0000 (15:54 +0100)
committerDavid Sherwood <david.sherwood@arm.com>
Fri, 10 Jun 2022 11:42:34 +0000 (12:42 +0100)
commit8daaea206b5905858bdbdd881be4fe9bdcc54516
treefcaeccc1ea2b715346a647631a397f49159fb0b4
parent46f08a4ee0e9169fdc153e2e4f9a5bb695372b27
[InstCombine] Use +0.0 instead of -0.0 as the FP identity for some folds

In foldSelectIntoOp we sometimes transform a select of a fadd into a
fadd of a select, where we select between data and an identity value.
For both fadd and fsub the identity is always -0.0, but if the nsz
flag is set on the select instruction we can use +0.0 instead. Doing
so then triggers other optimisations, such as when folding the select
of masked load into a new masked load.

Differential Revision: https://reviews.llvm.org/D126774
llvm/include/llvm/IR/Constants.h
llvm/lib/IR/Constants.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/test/Transforms/InstCombine/select-binop-foldable-floating-point.ll