[clang] [llvm] [HLSL] implement `mad` intrinsic (PR #83826)

Farzon Lotfi via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 4 10:23:25 PST 2024


================
@@ -19812,11 +19821,13 @@ bool Sema::SemaBuiltinElementwiseTernaryMath(CallExpr *TheCall) {
     Args[I] = Converted.get();
   }
 
-  int ArgOrdinal = 1;
-  for (Expr *Arg : Args) {
-    if (checkFPMathBuiltinElementType(*this, Arg->getBeginLoc(), Arg->getType(),
-                                      ArgOrdinal++))
-      return true;
+  if (enforceFloatingPointCheck) {
+    int ArgOrdinal = 1;
+    for (Expr *Arg : Args) {
+      if (checkFPMathBuiltinElementType(*this, Arg->getBeginLoc(),
+                                        Arg->getType(), ArgOrdinal++))
----------------
farzonl wrote:

So looking at `checkMathBuiltinElementType` it use of `isValidElementType` works for more than just matrix types  so  i think it is fine to use.  SO to be clear below is what you would like to see?

```cpp
if (CheckForFloatArgs) {
    int ArgOrdinal = 1;
    for (Expr *Arg : Args) {
      if (checkFPMathBuiltinElementType(*this, Arg->getBeginLoc(),
                                        Arg->getType(), ArgOrdinal++))
        return true;
    }
  } else  {
    int ArgOrdinal = 1;
    for (Expr *Arg : Args) {
      if (checkMathBuiltinElementType(*this, Arg->getBeginLoc(),
                                        Arg->getType(), ArgOrdinal++))
        return true;
}
```

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


More information about the cfe-commits mailing list