[PATCH] D129298: Add denormal-fp-math attribute for f16

David Candler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 08:53:58 PDT 2022


dcandler created this revision.
dcandler added reviewers: arsenm, spatel, echristo, andrew.w.kaylor, cameron.mcinally.
Herald added subscribers: jsji, kosarev, jdoerfert, pengfei, hiraditya, kristof.beyls, tpr.
Herald added a project: All.
dcandler requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay, wdng.
Herald added projects: clang, LLVM.

Denormal flushing behavior is currently controlled with the
denormal-fp-math attribute, with a denormal-fp-math-f32 variant for
targets such as AMDGPU where f32 denormals are controlled separately
from f16/f64. However there are other targets such as Arm (and I
think x86) where f16 denormals can be distinct from f32/f64. As the
attributes are now used for constant folding, this can lead to
incorrect folded values for half precision floats on those targets.

This patch adds a denormal-fp-math-f16 attribute, which functions
identically to denormal-fp-math-f32, but overrides the denormal
handling mode for f16 only. Constant folding tests have been
expanded to include half floats, and check both f16 and f32
variants of the attribute.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129298

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/IR/Function.cpp
  llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129298.442919.patch
Type: text/x-patch
Size: 39438 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220707/36e72486/attachment.bin>


More information about the llvm-commits mailing list