From: Alexey Bataev Date: Fri, 8 May 2015 11:47:16 +0000 (+0000) Subject: [OPENMP] Fixed atomic construct with non-integer expressions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c31eea2ad36584d299c0dafd006b04f73b65007c;p=clang [OPENMP] Fixed atomic construct with non-integer expressions. Do not emit 'atomicrmw' instruction for simple atomic constructs with non-integer expressions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236828 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp index 34e075925f..70db009193 100644 --- a/lib/CodeGen/CGStmtOpenMP.cpp +++ b/lib/CodeGen/CGStmtOpenMP.cpp @@ -1584,10 +1584,11 @@ static std::pair emitOMPAtomicRMW(CodeGenFunction &CGF, LValue X, // expression is simple and atomic is allowed for the given type for the // target platform. if (BO == BO_Comma || !Update.isScalar() || - !Update.getScalarVal()->getType()->isIntegerTy() || !X.isSimple() || - (!isa(Update.getScalarVal()) && - (Update.getScalarVal()->getType() != - X.getAddress()->getType()->getPointerElementType())) || + !Update.getScalarVal()->getType()->isIntegerTy() || + !X.isSimple() || (!isa(Update.getScalarVal()) && + (Update.getScalarVal()->getType() != + X.getAddress()->getType()->getPointerElementType())) || + !X.getAddress()->getType()->getPointerElementType()->isIntegerTy() || !Context.getTargetInfo().hasBuiltinAtomic( Context.getTypeSize(X.getType()), Context.toBits(X.getAlignment()))) return std::make_pair(false, RValue::get(nullptr)); diff --git a/test/OpenMP/atomic_update_codegen.cpp b/test/OpenMP/atomic_update_codegen.cpp index ada2e41114..b6d283224c 100644 --- a/test/OpenMP/atomic_update_codegen.cpp +++ b/test/OpenMP/atomic_update_codegen.cpp @@ -75,6 +75,9 @@ float2 float2x; register int rix __asm__("0"); int main() { +// CHECK-NOT: atomicrmw +#pragma omp atomic + ++dv; // CHECK: atomicrmw add i8* @{{.+}}, i8 1 monotonic #pragma omp atomic bx++;