[PATCH] D18276: [OpenMP] Allow reduction on pointer dereference

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 20 21:10:36 PDT 2016


ABataev added inline comments.

================
Comment at: lib/CodeGen/CGStmtOpenMP.cpp:913-929
@@ -912,9 +912,19 @@
         });
-      } else if (auto *ASE = dyn_cast<ArraySubscriptExpr>(IRef)) {
-        auto *Base = ASE->getBase()->IgnoreParenImpCasts();
-        while (auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
-          Base = TempASE->getBase()->IgnoreParenImpCasts();
+      } else if (isa<ArraySubscriptExpr>(IRef) || isa<UnaryOperator>(IRef)) {
+        const Expr *Array;
+        const Expr *Base;
+        if (auto* ASE = dyn_cast<ArraySubscriptExpr>(IRef)) {
+          Array = ASE;
+          Base = ASE->getBase()->IgnoreParenImpCasts();
+          while (auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
+            Base = TempASE->getBase()->IgnoreParenImpCasts();
+        } else {
+          auto* UO = cast<UnaryOperator>(IRef);
+          assert(UO->getOpcode() == UO_Deref && "should be a dereference");
+          Array = UO;
+          Base = UO->getSubExpr()->IgnoreParenImpCasts();
+        }
         auto *DE = cast<DeclRefExpr>(Base);
         auto *OrigVD = cast<VarDecl>(DE->getDecl());
-        auto ASELValue = EmitLValue(ASE);
+        auto ASELValue = EmitLValue(Array);
         auto OriginalBaseLValue = EmitLValue(DE);
----------------
This is not allowed by OpenMP standard. I added support for array subscripts because they are very similar to array sections, but unary operations are definitely not allowed


http://reviews.llvm.org/D18276





More information about the cfe-commits mailing list