Skip to content

Commit

Permalink
Merge pull request #8170 from tautschnig/bugfixes/gcc-shufflevector
Browse files Browse the repository at this point in the history
C front-end: GCC >= 12 support __builtin_shufflevector
  • Loading branch information
tautschnig authored Jan 26, 2024
2 parents 5bce1c3 + 3a0cc1a commit 270e82c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
15 changes: 13 additions & 2 deletions regression/cbmc/gcc_vector3/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ typedef union {
} vector_u;
#endif

int main()
void test_shuffle()
{
#if defined(__GNUC__) && !defined(__clang__)
// https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
Expand All @@ -31,7 +31,12 @@ int main()
assert(res.members[1] == 5);
assert(res.members[2] == 3);
assert(res.members[3] == 6);
#elif defined(__clang__)
#endif
}

void test_shufflevector(void)
{
#if defined(__clang__) || (defined(__GNUC__) && __GNUC__ >= 12)
v4si a = {1, 2, 3, 4};
v4si b = {5, 6, 7, 8};

Expand All @@ -50,3 +55,9 @@ int main()
assert(res.members[3] == 6);
#endif
}

int main()
{
test_shuffle();
test_shufflevector();
}
4 changes: 1 addition & 3 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2133,9 +2133,7 @@ void c_typecheck_baset::typecheck_side_effect_function_call(

return;
}
else if(
identifier == "__builtin_shufflevector" &&
config.ansi_c.mode == configt::ansi_ct::flavourt::CLANG)
else if(identifier == "__builtin_shufflevector")
{
exprt result = typecheck_shuffle_vector(expr);
expr.swap(result);
Expand Down

0 comments on commit 270e82c

Please sign in to comment.