[PATCH] D84324: AMDGPU/GlobalISel: Lower G_FREM

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 08:27:02 PDT 2020


arsenm added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:2738
+        MIRBuilder.buildInstr(TargetOpcode::G_FDIV, {Ty}, {Src0Reg, Src1Reg});
+    auto Floor = MIRBuilder.buildInstr(TargetOpcode::G_FFLOOR, {Ty}, {Div});
+    auto Mul = MIRBuilder.buildFMul(Ty, Floor, Src1Reg);
----------------
Petar.Avramovic wrote:
> arsenm wrote:
> > arsenm wrote:
> > > buildFFloor?
> > Is this a correct handling of frem? The AMDGPU dag expansion uses ISD::FTRUNC, but I'm not sure that was ever correct
> The G_FPTRUNC complains about src and dst being same size, I hit
>     assert(DstTy.getSizeInBits() < SrcTy.getSizeInBits() &&
>            "invalid widening trunc");
> from the variable name I thought that FFloor could work but I guess that it works only when operands have same sign. (btw vulkan cts tests where I saw this passed).
> Dag expansion seems correct from the description of fmod/frem.
> This generic instruction here should discard digits after decimal point, do we have such instruction? 
ISD::FTRUNC is G_INTRINSIC_TRUNC

I'm not really clear on what frem really is, or if it's really supposed to be the same as OpenCL fmod


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

https://reviews.llvm.org/D84324





More information about the llvm-commits mailing list