Skip to content

Commit bda5bf1

Browse files
committed
Add support for __builtin_elementwise_{add,sub}_sat
Clang uses these builtins in SIMD operations.
1 parent 993cf02 commit bda5bf1

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,7 +2169,9 @@ void c_typecheck_baset::typecheck_side_effect_function_call(
21692169
}
21702170
else if(
21712171
identifier == CPROVER_PREFIX "saturating_minus" ||
2172-
identifier == CPROVER_PREFIX "saturating_plus")
2172+
identifier == CPROVER_PREFIX "saturating_plus" ||
2173+
identifier == "__builtin_elementwise_add_sat" ||
2174+
identifier == "__builtin_elementwise_sub_sat")
21732175
{
21742176
exprt result = typecheck_saturating_arithmetic(expr);
21752177
expr.swap(result);
@@ -3842,10 +3844,18 @@ exprt c_typecheck_baset::typecheck_saturating_arithmetic(
38423844
}
38433845

38443846
exprt result;
3845-
if(identifier == CPROVER_PREFIX "saturating_minus")
3847+
if(
3848+
identifier == CPROVER_PREFIX "saturating_minus" ||
3849+
identifier == "__builtin_elementwise_sub_sat")
3850+
{
38463851
result = saturating_minus_exprt{expr.arguments()[0], expr.arguments()[1]};
3847-
else if(identifier == CPROVER_PREFIX "saturating_plus")
3852+
}
3853+
else if(
3854+
identifier == CPROVER_PREFIX "saturating_plus" ||
3855+
identifier == "__builtin_elementwise_add_sat")
3856+
{
38483857
result = saturating_plus_exprt{expr.arguments()[0], expr.arguments()[1]};
3858+
}
38493859
else
38503860
UNREACHABLE;
38513861

0 commit comments

Comments
 (0)