Skip to content

Commit 9cb29f5

Browse files
committed
Fix valid FC values for unsigned AMO load builtins
1 parent 4b51574 commit 9cb29f5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

clang/lib/Sema/SemaPPC.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,12 @@ bool SemaPPC::CheckPPCBuiltinFunctionCall(const TargetInfo &TI,
261261
if (SemaRef.BuiltinConstantArg(TheCall, 2, Result))
262262
return true;
263263
unsigned Val = Result.getZExtValue();
264-
if ((Val <= 8) || Val == 16 || (Val >= 24 && Val <= 25) || Val == 28)
264+
static constexpr unsigned ValidFC[] = {0, 1, 2, 3, 4, 6, 8, 16, 24, 25, 28};
265+
if (llvm::is_contained(ValidFC, Val))
265266
return false;
266267
Expr *Arg = TheCall->getArg(2);
267268
return SemaRef.Diag(Arg->getBeginLoc(), diag::err_argument_invalid_range)
268-
<< toString(Result, 10) << "0-8, 16, 24-25" << "28"
269+
<< toString(Result, 10) << "0-4, 6, 8, 16, 24-25" << "28"
269270
<< Arg->getSourceRange();
270271
}
271272
}

clang/test/CodeGen/PowerPC/builtins-amo-err.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ void test_amo() {
77
unsigned int *ptr1, value1;
88
// AIX32-ERROR: error: this builtin is only available on 64-bit targets
99
__builtin_amo_lwat(ptr1, value1, 0);
10-
// FC-ERROR: argument value 9 is outside the valid range [0-8, 16, 24-25, 28]
10+
// FC-ERROR: argument value 9 is outside the valid range [0-4, 6, 8, 16, 24-25, 28]
1111
__builtin_amo_lwat(ptr1, value1, 9);
1212

1313
unsigned long int *ptr2, value2;
1414
// AIX32-ERROR: error: this builtin is only available on 64-bit targets
1515
__builtin_amo_ldat(ptr2, value2, 3);
16-
// FC-ERROR: error: argument value 26 is outside the valid range [0-8, 16, 24-25, 28]
16+
// FC-ERROR: error: argument value 26 is outside the valid range [0-4, 6, 8, 16, 24-25, 28]
1717
__builtin_amo_ldat(ptr2, value2, 26);
1818
}

0 commit comments

Comments
 (0)