generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 129
Closed
Description
I'm not sure where in the translation process this should happen, but consider the following program:
#![feature(repr_simd)]
#[repr(simd)]
#[derive(PartialEq, Eq)]
pub struct A(i64, i64);
fn main() {
let x = A(1, 2);
let y = A(3, 4);
assert!(x != y);
}
The generated C code from --gen-c does comparison like this:
_Bool _RNvXs_Csb7rQPrKk64Y_4mainNtB4_1ANtNtCs75dudyTCRYy_4core3cmp9PartialEq2neB4_(long int __attribute__((vector_size (2*sizeof(long int)))) *self, long int __attribute__((vector_size (2*sizeof(long int)))) *other)
{
// ...
long int *__self_1_0;
long int *__self_1_1;
long int *__self_0_0;
long int *__self_0_1;
// ...
__self_1_0 = *other;
__self_1_1 = &(*other)[1];
__self_0_0 = *self;
__self_0_1 = &(*self)[1];
var_8 = *__self_0_0;
var_9 = *__self_1_0;
var_7 = var_8 != var_9;
// ...
}
There are two main issues:
__self_1_0 = *other;: the value*otheris a vector type, while__self_1_0is along int*__self_1_1 = &(*other)[1];: this leads to "address of vector element requested"; you cannot take reference to a vector element in C.
No longer relevant: The --gen-c-runnable transformation handles this by casting the vector to a raw pointer and using array indexing, but long-term this should be fixed at the CBMC level.
Metadata
Metadata
Assignees
Labels
No labels