[PATCH] D75179: [AMDGPU][ConstantFolding] Fold llvm.amdgcn.fract intrinsic

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 26 07:35:42 PST 2020


arsenm added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1797
+    if (IntrinsicID == Intrinsic::amdgcn_fract) {
+      // TODO what should amdgcn_fract return for tiny negative arguments?
+      // GLSL defines fract(x) as x - floor(x).
----------------
This should match the instruction behavior (although I guess we can ignore the bug on SI)


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:1798-1801
+      // GLSL defines fract(x) as x - floor(x).
+      // OpenCL defines fract(x) as fmin(x - floor(x), 0x1.fffffep-1f): "The
+      //   min() operator is there to prevent fract(-small) from returning 1.0.
+      //   It returns the largest positive floating-point number less than 1.0."
----------------
The specs aren't necessarily relevant here, since this just needs to match the instruction behavior. Talking about the min when it isn't here is potentially confusing


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75179/new/

https://reviews.llvm.org/D75179





More information about the llvm-commits mailing list