On 06/10/2016 12:48 PM, Segher Boessenkool wrote:
Currently, optimize_bit_field_compare reads the bitfield in word_mode
if it can.  If the bit field is normally accessed in a smaller mode,
this might be a violation of the memory model, although the "extra"
part of the read is not used.  But also, previous stores to the bit
field will have been done in the smaller mode, and then bigger loads
from it cause a LHS problem.

Bootstrapped and regchecked on powerpc64-linux.  Is this okay for
trunk?


Segher


2016-06-10  Segher Boessenkool  <seg...@kernel.crashing.org>

        PR middle-end/71310
        * fold-const.c (optimize_bit_field_compare): Don't try to use
        word_mode unconditionally for reading the bit field, look at
        DECL_BIT_FIELD_REPRESENTATIVE instead.
Testcase? It would seem to me that you could make a ppc testcase without major difficulties from either of the tests in the BZ.

The change itself is fine, and it's approved with a testcase or at least an explanation of why you can't turn either of the tests from the BZ into a testcase in our framework.

I do note there's two more calls to get_best_mode that unconditionally uses word_mode in fold_truth_andor_1. I think in that case we're looking to try and loads of adjacent fields that are being compared. I haven't thought much about whether or not it's safe WRT the C++11 memory model.


Jeff

Reply via email to