[clang] [HLSL] Add support for modulo of floating point scalar and vectors (PR #135125)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 10 07:13:48 PDT 2025


================
@@ -3964,6 +3964,8 @@ Value *ScalarExprEmitter::EmitRem(const BinOpInfo &Ops) {
 
   if (Ops.Ty->hasUnsignedIntegerRepresentation())
     return Builder.CreateURem(Ops.LHS, Ops.RHS, "rem");
+  else if (CGF.getLangOpts().HLSL && Ops.Ty->hasFloatingRepresentation())
+    return Builder.CreateFRem(Ops.LHS, Ops.RHS, "rem");
   else
----------------
llvm-beanz wrote:

I know this steps a little out from the code you're changing, but it would be a nice cleanup (https://llvm.org/docs/CodingStandards.html#don-t-use-else-after-a-return).
```suggestion
  if (CGF.getLangOpts().HLSL && Ops.Ty->hasFloatingRepresentation())
    return Builder.CreateFRem(Ops.LHS, Ops.RHS, "rem");
```

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


More information about the cfe-commits mailing list