[all-commits] [llvm/llvm-project] 5da674: IR: Add nofpclass parameter attribute

Matt Arsenault via All-commits all-commits at lists.llvm.org
Fri Feb 24 03:41:45 PST 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5da674492a5acf8e08a58f611e39ff4cd6a16dfe
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2023-02-24 (Fri, 24 Feb 2023)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/docs/ReleaseNotes.rst
    M llvm/include/llvm/AsmParser/LLParser.h
    M llvm/include/llvm/AsmParser/LLToken.h
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    M llvm/include/llvm/IR/Argument.h
    M llvm/include/llvm/IR/Attributes.h
    M llvm/include/llvm/IR/Attributes.td
    M llvm/include/llvm/IR/Function.h
    M llvm/include/llvm/IR/InstrTypes.h
    M llvm/lib/Analysis/ValueTracking.cpp
    M llvm/lib/AsmParser/LLLexer.cpp
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/IR/AttributeImpl.h
    M llvm/lib/IR/Attributes.cpp
    M llvm/lib/IR/Function.cpp
    M llvm/lib/IR/Instructions.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Transforms/Utils/CodeExtractor.cpp
    A llvm/test/Assembler/nofpclass-invalid.ll
    A llvm/test/Assembler/nofpclass.ll
    M llvm/test/Bitcode/compatibility.ll
    M llvm/test/Transforms/InstSimplify/known-never-nan.ll
    A llvm/test/Transforms/Util/nofpclass.ll
    A llvm/test/Verifier/nofpclass.ll
    M llvm/unittests/IR/VerifierTest.cpp

  Log Message:
  IR: Add nofpclass parameter attribute

This carries a bitmask indicating forbidden floating-point value kinds
in the argument or return value. This will enable interprocedural
-ffinite-math-only optimizations. This is primarily to cover the
no-nans and no-infinities cases, but also covers the other floating
point classes for free. Textually, this provides a number of names
corresponding to bits in FPClassTest, e.g.

  call nofpclass(nan inf) @must_be_finite()
  call nofpclass(snan) @cannot_be_snan()

This is more expressive than the existing nnan and ninf fast math
flags. As an added bonus, you can represent fun things like nanf:

  declare nofpclass(inf zero sub norm) float @only_nans()

Compared to nnan/ninf:
  - Can be applied to individual call operands as well as the return value
  - Can distinguish signaling and quiet nans
  - Distinguishes the sign of infinities
  - Can be safely propagated since it doesn't imply anything about
    other operands.
  - Does not apply to FP instructions; it's not a flag

This is one step closer to being able to retire "no-nans-fp-math" and
"no-infs-fp-math". The one remaining situation where we have no way to
represent no-nans/infs is for loads (if we wanted to solve this we
could introduce !nofpclass metadata, following along with

This is to help simplify the GPU builtin math library
distribution. Currently the library code has explicit finite math only
checks, read from global constants the compiler driver needs to set
based on the compiler flags during linking. We end up having to
internalize the library into each translation unit in case different
linked modules have different math flags. By propagating known-not-nan
and known-not-infinity information, we can automatically prune the
edge case handling in most functions if the function is only reached
from fast math uses.

  Commit: c0db240e5167885cc8083d72db85c80f5b7eb936
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2023-02-24 (Fri, 24 Feb 2023)

  Changed paths:
    M llvm/docs/AMDGPUUsage.rst

  Log Message:
  AMDGPU: Document denormal behavior

Not sure this is the right place for it next to the table.

Compare: https://github.com/llvm/llvm-project/compare/bb0403ae2e8f...c0db240e5167

More information about the All-commits mailing list