[all-commits] [llvm/llvm-project] 63b17e: [RISCV] Add strictfp support for compares.

Craig Topper via All-commits all-commits at lists.llvm.org
Tue Jan 11 20:35:09 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 63b17eb9ec106540ee5cb91d285027512072a050
      https://github.com/llvm/llvm-project/commit/63b17eb9ec106540ee5cb91d285027512072a050
  Author: Craig Topper <craig.topper at sifive.com>
  Date:   2022-01-11 (Tue, 11 Jan 2022)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
    M llvm/lib/Target/RISCV/RISCVISelLowering.cpp
    M llvm/lib/Target/RISCV/RISCVInstrFormats.td
    M llvm/lib/Target/RISCV/RISCVInstrInfo.td
    M llvm/lib/Target/RISCV/RISCVInstrInfoD.td
    M llvm/lib/Target/RISCV/RISCVInstrInfoF.td
    M llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
    A llvm/test/CodeGen/RISCV/double-fcmp-strict.ll
    A llvm/test/CodeGen/RISCV/float-fcmp-strict.ll
    A llvm/test/CodeGen/RISCV/half-fcmp-strict.ll

  Log Message:
  -----------
  [RISCV] Add strictfp support for compares.

This adds support for STRICT_FSETCC(quiet) and STRICT_FSETCCS(signaling).

FEQ matches well to STRICT_FSETCC oeq.
FLT/FLE matches well to STRICT_FSETCCS olt/ole.

Others require commuting operands or multiple instructions.

STRICT_FSETCC olt/ole/ogt/oge/ult/ule/ugt/uge uses FLT/FLE,
but we need to save/restore FFLAGS around them to avoid spurious
exceptions. I've implemented pseudo instructions with a
CustomInserter to insert the save/restore CSR instructions.
Unfortunately, this doesn't honor exceptions for signaling NANs
but I'm not sure if signaling nans are really supported by the
constrained intrinsics.

STRICT_FSETCC one and ueq expand to a pair of FLT instructions
with a save/restore of fflags around each. This could be improved
in the future.

There may be some opportunities to generate better code for strict
comparisons mixed with nonans fast math flags. I've left FIXMEs in
the .td files for that.

Co-Authored-by: ShihPo Hung <shihpo.hung at sifive.com>

Reviewed By: arcbbb

Differential Revision: https://reviews.llvm.org/D116694




More information about the All-commits mailing list