Richard Guenther wrote:
This transformation is indeed invalid according to our type-based alias
rules. There is no 'easy' way to make it work (well, force
-fno-strict-aliasing)
other than to make the access through a pointer to a union. That is:
union {
struct s;
long long int x;
} *cilsimp.3 = (union ... *)p.0;
cilsimp.1 = cilsimp.3->x;
Thank for the tip, I'll try that out. Will it work even if I have to introduce a
whole structure with 'container fields' matching the original bit-fields, as for
example:
struct original_struct {
int a : 32;
int b : 32;
int c : 16;
int d : 8;
int e : 8;
} s;
int a = s->d;
Which I might turn into
union {
struct orignal_struct s;
struct container_struct {
long long int a_and_b;
long int c_d_and_e;
} c;
} *container_ptr = (union ... *)s;
container = container_ptr->c.c_d_and_e;
a = (container << 16) >> 8;
Or you can try using a VIEW_CONVERT_EXPR (I don't know if this will
work, you'll have to try):
cilsimp.1 = VIEW_CONVERT_EXPR<long long int>(*p);
If I understand it correctly that might tell gcc that cilsimp.1 could basically
alias with everything else. That would defeat a lot of optimizations though.
Since my aim is to let the optimizer clean up the mess resulting from removing
bit-field accesses I guess that using your above suggestion should be better.
Thanks again
Gabriele