[OPENMP] Fixed atomic construct with non-integer expressions.

Do not emit 'atomicrmw' instruction for simple atomic constructs with non-integer expressions.

llvm-svn: 236828
This commit is contained in:
Alexey Bataev 2015-05-08 11:47:16 +00:00
parent b9bfd969e3
commit 9d541a72e8
2 changed files with 8 additions and 4 deletions

View File

@ -1584,10 +1584,11 @@ static std::pair<bool, RValue> 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<llvm::ConstantInt>(Update.getScalarVal()) &&
(Update.getScalarVal()->getType() !=
X.getAddress()->getType()->getPointerElementType())) ||
!Update.getScalarVal()->getType()->isIntegerTy() ||
!X.isSimple() || (!isa<llvm::ConstantInt>(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));

View File

@ -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++;