On Mon, 20 Oct 2014, Alan Modra wrote:
> You were correct to be suspicious that we weren't simplifying as we
> should. After more time in the debugger than I care to admit, I found
> the underlying cause.
>
> One of the var loc expressions is
> (plus:SI (plus:SI (not:SI (debug_expr:SI D#9))
> (value/u:SI 58:4373 @0x18d3968/0x18ef230))
> (debug_expr:SI D#5))
>
> which after substitution (in bb7) becomes
> (plus:SI (plus:SI (not:SI (plus:SI (reg:SI 5 5 [orig:212 D.2333 ] [212])
> (const:SI (plus:SI (symbol_ref:SI ("*.LANCHOR0") [flags
> 0x182])
> (const_int -1 [0xffffffffffffffff])))))
> (reg:SI 10 10 [orig:223 ivtmp.33 ] [223]))
> (plus:SI (reg:SI 5 5 [orig:212 D.2333 ] [212])
> (const:SI (plus:SI (symbol_ref:SI ("*.LANCHOR0") [flags 0x182])
> (const_int 323 [0x143])))))
>
> The above has 8 ops by the time you turn ~x into -x - 1, and exceeds
> the allowed number of elements in the simplify_plus_minus ops array.
> Note that the ops array has 8 elements but the code only allows 7 to
> be entered, a bug since the "spare" element isn't a sentinal or used
> in any other way.
>
> This resulted in a partial simplification of the expression to
> (plus:SI (plus:SI (reg:SI 10 10 [orig:223 ivtmp.33 ] [223])
> (symbol_ref:SI ("*.LANCHOR0") [flags 0x182]))
> (const:SI (minus:SI (const_int 323 [0x143])
> (symbol_ref:SI ("*.LANCHOR0") [flags 0x182]))))
>
> I also noticed another small bug in simplify_plus_minus. n_constants
> ought to be the number of constants in ops, not the number of times
> we look at a constant.
>
> The "Handle CONST wrapped NOT, NEG and MINUS" in the previous patch
> seems to no longer be necessary, so I took that out (didn't hit the
> code in powerpc64-linux, powerpc-linux and x86_64-linux bootstrap and
> regression tests).
>
> Bootstrapped and regression tested powerpc64-linux and x86_64-linux.
For the record, I have now regression-tested your updated change too with
my usual powerpc-gnu-linux multilibs:
-mcpu=603e
-mcpu=603e -msoft-float
-mcpu=8540 -mfloat-gprs=single -mspe=yes -mabi=spe
-mcpu=8548 -mfloat-gprs=double -mspe=yes -mabi=spe
-mcpu=7400 -maltivec -mabi=altivec
-mcpu=e6500 -maltivec -mabi=altivec
-mcpu=e5500 -m64
-mcpu=e6500 -m64 -maltivec -mabi=altivec
observing no issues. Thanks for the fix!
Maciej