[DAGCombiner] Expand combining of FP logical ops to sign-setting FP ops
authorNemanja Ivanovic <nemanja.i.ibm@gmail.com>
Tue, 9 Oct 2018 23:20:11 +0000 (23:20 +0000)
committerNemanja Ivanovic <nemanja.i.ibm@gmail.com>
Tue, 9 Oct 2018 23:20:11 +0000 (23:20 +0000)
commit72d4866e57666057e5d8c3e51065e9f895f37f29
tree361ba4185107856c43c39303a5330939b79e3bd4
parent5c7bf1a75652ef73968b3737d44ea4bd2fe49673
[DAGCombiner] Expand combining of FP logical ops to sign-setting FP ops

We already do the following combines:
(bitcast int (and (bitcast fp X to int), 0x7fff...) to fp) -> fabs X
(bitcast int (xor (bitcast fp X to int), 0x8000...) to fp) -> fneg X

When the target has "bit preserving fp logic". This patch just extends it
to also combine:
(bitcast int (or (bitcast fp X to int), 0x8000...) to fp) -> fneg (fabs X)

As some targets have fnabs and even those that don't can efficiently lower
both the fabs and the fneg.

Differential revision: https://reviews.llvm.org/D44548

llvm-svn: 344093
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/test/CodeGen/AArch64/fabs.ll
llvm/test/CodeGen/PowerPC/float-logic-ops.ll
llvm/test/CodeGen/X86/fp-logic.ll