[PATCH] D18276: [OpenMP] Allow reduction on pointer dereference
Jonas Hahnfeld via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 21 00:44:33 PDT 2016
Hahnfeld abandoned this revision.
================
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);
----------------
ABataev wrote:
> 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
Ok, I'm fine with that and will close this revision.
(for me `*arr` is the same as `arr[0]` so I expected it to work as well)
http://reviews.llvm.org/D18276
More information about the cfe-commits
mailing list