Hi,
I'm looking for some help understanding how BIT_FIELD_REFs work with big-endian.
Vector subscripts in this example:
#define vector __attribute__((vector_size(sizeof(int)*4) ))
typedef int vec vector;
int foo(vec a)
{
return a[0];
}
gets lowered into array accesses by c-typeck.c
;; Function foo (null)
{
return *(int *) &a;
}
and gets gimplified into BIT_FIELD_REFs a bit later.
foo (vec a)
{
int _2;
<bb 2>:
_2 = BIT_FIELD_REF <a_3(D), 32, 0>;
return _2;
}
What's interesting to me here is the bitpos - does this not need
BYTES_BIG_ENDIAN correction? This seems to be inconsistenct with what happens
with reduction operations in the autovectorizer where the scalar result in the
reduction epilogue gets extracted with a BIT_FIELD_REF but the bitpos there is
corrected for BIG_ENDIAN.
... from tree-vect-loop.c:vect_create_epilog_for_reduction ()
/* 2.4 Extract the final scalar result. Create:
s_out3 = extract_field <v_out2, bitpos> */
if (extract_scalar_result)
{
tree rhs;
if (dump_enabled_p ())
dump_printf_loc (MSG_NOTE, vect_location,
"extract scalar result");
if (BYTES_BIG_ENDIAN)
bitpos = size_binop (MULT_EXPR,
bitsize_int (TYPE_VECTOR_SUBPARTS (vectype) - 1),
TYPE_SIZE (scalar_type));
else
bitpos = bitsize_zero_node;
For eg:
int foo(int * a)
{
int i, sum = 0;
for (i=0;i<16;i++)
sum += a[i];
return sum;
}
gets autovectorized into:
...
vect_sum_9.17_74 = [reduc_plus_expr] vect_sum_9.15_73;
stmp_sum_9.16_75 = BIT_FIELD_REF <vect_sum_9.17_74, 32, 96>;
sum_76 = stmp_sum_9.16_75 + sum_47;
the BIT_FIELD_REF here seems to have been corrected for BYTES_BIG_ENDIAN
If vec_extract is defined in the back-end, how does one figure out if the
BIT_FIELD_REF is a product of the gimplifier's indirect ref folding or the
vectorizer's bit-field extraction and apply the appropriate correction in
vec_extract's expansion? Or am I missing something that corrects BIT_FIELD_REFs
between the gimplifier and the RTL expander?
Thanks,
Tejas.