[PATCH] D117687: [RISCV] Optimize lowering of floating-point -0.0

Fraser Cormack via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 19 08:36:26 PST 2022


frasercrmck created this revision.
frasercrmck added reviewers: jrtc27, rogfer01, asb, craig.topper.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
frasercrmck requested review of this revision.
Herald added subscribers: llvm-commits, eopXD, MaskRay.
Herald added a project: LLVM.

This idea has come up in several reviews -- D115978 <https://reviews.llvm.org/D115978> and D105902 <https://reviews.llvm.org/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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117687

Files:
  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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117687.401260.patch
Type: text/x-patch
Size: 31501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220119/c62120d1/attachment.bin>


More information about the llvm-commits mailing list