[clang] [mlir] [OpenACC] Implement tile/collapse lowering (PR #138576)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue May 6 06:20:45 PDT 2025


================
@@ -336,6 +348,52 @@ class OpenACCClauseCIREmitter final
       return clauseNotImplemented(clause);
     }
   }
+
+  void VisitCollapseClause(const OpenACCCollapseClause &clause) {
+    if constexpr (isOneOfTypes<OpTy, mlir::acc::LoopOp>) {
+      llvm::APInt value =
+          clause.getIntExpr()->EvaluateKnownConstInt(cgf.cgm.getASTContext());
+
+      if (value.getBitWidth() != 64)
+        value = value.sext(64);
----------------
erichkeane wrote:

The actual value in the APInt cannot be > 64 bits, it is the count of loop-depth and is checked elsewhere, so the compiler would have broken elsewhere if this was the case.

However, the type of the expression itself could possibly be?  So I'll switch this to a sextOrTrunc.

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


More information about the cfe-commits mailing list