[PATCH] D84324: AMDGPU/GlobalISel: Lower G_FREM

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 22 08:22:32 PDT 2020


Petar.Avramovic marked an inline comment as done.
Petar.Avramovic 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);
----------------
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? 


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

https://reviews.llvm.org/D84324





More information about the llvm-commits mailing list