[PATCH] D120150: Constant folding of llvm.amdgcn.trig.preop

Ravi Korsa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 18 23:38:31 PST 2022


Ravi added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp:1009
+      Thi >>= 11;
+      double Res = (double)Thi;
+      int Scale = -53 - Shift;
----------------
arsenm wrote:
> Should stick with apfloat operations
Yes, will do that.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp:1013
+        Scale += 128;
+      Res = ldexp(Res, Scale);
+      return IC.replaceInstUsesWith(II, ConstantFP::get(Src->getType(), Res));
----------------
arsenm wrote:
> You can use scalbn for APFloat instead of relying on host ldexp
Yes..will try it out and check for any precision difference. Should be good as long as the internal implementation of APFloat is within 0.5 ULP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120150



More information about the llvm-commits mailing list