https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65449

--- Comment #4 from ma.jiang at zte dot com.cn ---
Hi Bernd,
  Thanks for your apply.

(In reply to Bernd Edlinger from comment #3)
> Yes, but that is not the fault of the strict volatile code path any more.
//  Sure,I agree with you. The redundant read  is another problem. In fact, it
should be named as "volatile pointer dereference produce redundant read".

> For bit-fields this redundant read is exactly what AAPCS demands:
> 
//   Yes.I know that volatile bitfiled need the redundant read. That is why I
thought there were connections between the redundant read and
-fstrict-volatile-bitfields originally.

> IMO, the problem is this:
> 
> In store_fixed_bit_field_1 we do not know if the access is on a
> packed structure member where the extra read is not necessary,
> or if we have a bit-field where the extra read would be mandatory,
> even if the complete container is overwritten.
// I agree that the problem is caused by the store_fixed_bit_field_1.But,I
disgree with you about three things.First,the redundant read should not appear
if -fstrict-volatile-bitfields was off. Second, in store_fixed_bit_field_1 we
can distinguish pointer dereference from structure member
access(e.g.,MEM_EXPR(op0) will tell us whether op0 is a componet_ref or not, if
MEM_P(op0) is true). Third, as gcc manual said "-fstrict-volatile-bitfields
:This option should be used if accesses to volatile bit-fields (or other
structure fields, although the compiler usually honors those types anyway)
should use a single access of the width of the field’s type, aligned to a
natural alignment if possible.", store_fixed_bit_field_1 does not need to
distinguish bitfields from normal structure member.

> 
> BTW: What happens in your example if you use -O0? Isn't there still an
> unaligned stw access?  That's because you example is in a way invalid C.
> You can't set an int* to an unaligned address, it must be at least
> aligned to the GET_MODE_ALIGNMENT(SImode).
//Yes, I know what you mean. Split access is a auxiliary fuction provided by
compiler with the help of data analysis.As -O0 turn off all analysis , an
unaligned stw is acceptable. And ,BTW, the C standard said nothing about
unaligned access as I know. Could you show me something about it?

Reply via email to