Skip to content

Commit eec8e61

Browse files
committed
Support shuffle_vector_exprt in goto programs
de4557f added support for _builtin_shuffle/__builtin_shufflevector via a shuffle_vector_exprt. This expression, however, was lowered right away in the C front end, making it unavailable to other language front-ends. By moving the lowering to `remove_vector` there no longer is such a limitation. Kani will be able to use it directly for Rust programs. Regression test cbmc/gcc_vector3 continues to pass, demonstrating that processing via the C front-end works as before. Fixes: #6297
1 parent 3f175c9 commit eec8e61

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/ansi-c/c_typecheck_gcc_polymorphic_builtins.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ exprt c_typecheck_baset::typecheck_shuffle_vector(
14591459
operands.push_back(std::move(mod_index));
14601460
}
14611461

1462-
return shuffle_vector_exprt{arg0, arg1, std::move(operands)}.lower();
1462+
return shuffle_vector_exprt{arg0, arg1, std::move(operands)};
14631463
}
14641464
else if(identifier == "__builtin_shufflevector")
14651465
{
@@ -1509,8 +1509,8 @@ exprt c_typecheck_baset::typecheck_shuffle_vector(
15091509
}
15101510
}
15111511

1512-
return shuffle_vector_exprt{arguments[0], arguments[1], std::move(operands)}
1513-
.lower();
1512+
return shuffle_vector_exprt{
1513+
arguments[0], arguments[1], std::move(operands)};
15141514
}
15151515
else
15161516
UNREACHABLE;

src/goto-programs/remove_vector.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Date: September 2014
1616
#include <util/arith_tools.h>
1717
#include <util/std_expr.h>
1818

19+
#include <ansi-c/c_expr.h>
20+
1921
#include "goto_model.h"
2022

2123
static bool have_to_remove_vector(const typet &type);
@@ -41,6 +43,8 @@ static bool have_to_remove_vector(const exprt &expr)
4143
{
4244
return true;
4345
}
46+
else if(expr.id() == ID_shuffle_vector)
47+
return true;
4448
else if(expr.id()==ID_vector)
4549
return true;
4650
}
@@ -93,6 +97,14 @@ static void remove_vector(exprt &expr)
9397
if(!have_to_remove_vector(expr))
9498
return;
9599

100+
if(expr.id() == ID_shuffle_vector)
101+
{
102+
exprt result = to_shuffle_vector_expr(expr).lower();
103+
remove_vector(result);
104+
expr.swap(result);
105+
return;
106+
}
107+
96108
Forall_operands(it, expr)
97109
remove_vector(*it);
98110

0 commit comments

Comments
 (0)