[clang] [NVPTX] Add support for maxclusterrank in launch_bounds (PR #66496)

via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 21 03:42:23 PDT 2023


================
@@ -537,59 +537,52 @@ void NVPTXAsmPrinter::emitKernelFunctionDirectives(const Function &F,
                                                    raw_ostream &O) const {
   // If the NVVM IR has some of reqntid* specified, then output
   // the reqntid directive, and set the unspecified ones to 1.
-  // If none of reqntid* is specified, don't output reqntid directive.
-  unsigned reqntidx, reqntidy, reqntidz;
-  bool specified = false;
-  if (!getReqNTIDx(F, reqntidx))
-    reqntidx = 1;
-  else
-    specified = true;
-  if (!getReqNTIDy(F, reqntidy))
-    reqntidy = 1;
-  else
-    specified = true;
-  if (!getReqNTIDz(F, reqntidz))
-    reqntidz = 1;
-  else
-    specified = true;
-
-  if (specified)
-    O << ".reqntid " << reqntidx << ", " << reqntidy << ", " << reqntidz
+  // If none of Reqntid* is specified, don't output reqntid directive.
+  unsigned Reqntidx, Reqntidy, Reqntidz;
+  Reqntidx = Reqntidy = Reqntidz = 1;
+  bool ReqSpecified = false;
+  if (getReqNTIDx(F, Reqntidx))
+    ReqSpecified |= true;
+  if (getReqNTIDy(F, Reqntidy))
+    ReqSpecified |= true;
+  if (getReqNTIDz(F, Reqntidz))
+    ReqSpecified |= true;
----------------
ldrumm wrote:

I think I know what you were going for with those ors:
```suggestion
    ReqSpecified |= getReqNTIDx(F, Reqntidx);
    ReqSpecified |= getReqNTIDy(F, Reqntidy);
    ReqSpecified |= getReqNTIDz(F, Reqntidz);
```

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


More information about the cfe-commits mailing list