[llvm] [AMDGPU] Fix legalization of frem(-0.0, y) (PR #70448)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 06:36:46 PST 2023


================
@@ -2341,6 +2341,14 @@ bool AMDGPULegalizerInfo::legalizeFceil(
   return true;
 }
 
+static bool allowNoSignedZeros(const MachineFunction &MF, unsigned Flags) {
+  return (Flags & MachineInstr::FmNsz) ||
+         MF.getTarget().Options.NoSignedZerosFPMath;
+}
+
+// Legalize frem(x, y) -> copysign(x - y * trunc(x / y), x)
+// The copysign is only required to get the correct result -0.0 when x is -0.0
+// (and y is non-zero). With NSZ it can be dropped.
----------------
jayfoad wrote:

Could also drop it if isKnownNeverZero(x)?

https://github.com/llvm/llvm-project/pull/70448


More information about the llvm-commits mailing list