[RISCV] Optimize lowering of floating-point -0.0
authorFraser Cormack <fraser@codeplay.com>
Wed, 19 Jan 2022 16:17:59 +0000 (16:17 +0000)
committerFraser Cormack <fraser@codeplay.com>
Thu, 20 Jan 2022 11:46:28 +0000 (11:46 +0000)
commit5a12024b95e4bdac8719f18a0e58c692aa471534
tree9a21c8b7daed1a90946e14f975f6922b8ac427b6
parent770353cd94f829f5013e21d8846d516b8cb095a2
[RISCV] Optimize lowering of floating-point -0.0

This idea has come up in several reviews -- D115978 and D105902 -- so I
can't take any credit for the idea. Instead of using a constant pool to
lower -0.0, we can emit a sequence of two instructions:

    fmv.[hwd].x freg, zero
    fsgnjn.[hsd] freg, freg, freg

This is only done when the floating-point type is legal.

Reviewed By: craig.topper

Differential Revision: https://reviews.llvm.org/D117687
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoD.td
llvm/lib/Target/RISCV/RISCVInstrInfoF.td
llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
llvm/test/CodeGen/RISCV/fp-imm.ll
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-reduction-fp.ll
llvm/test/CodeGen/RISCV/rvv/vreductions-fp-sdnode.ll
llvm/test/CodeGen/RISCV/zfh-imm.ll