The following two patches each fix PR63148, a wrong-code issue
caused by bogus array indices a-la
&global_data.b[(sizetype) i + 536870911] which have a correct
address when lowered but bogus index.
The case in question can be mitigated by disabling folding of
(sizetype) i * 8 + 4294967288 to ((sizetype) i + 536870911) * 8
but that makes the real error - the existence of
try_move_mult_to_index - just harder to trigger (I have already
removed all similar code over the years).
So the second variant is removing try_move_mult_to_index.
The wrong-code is a regression from 4.7 which means a fix
for the branches would be nice as well.
Removing try_move_mult_to_index makes us correctly detect
the dependence and not vectorize the testcase while only
doing the mitigation makes dependence analysis fail and
we create a runtime alias check (which would be a regression
as well here - 4.7 also didn't vectorize this by detecting
the dependence).
I'm not sure which patch has the least side-effects on the
branches.
Sofar I have only fully tested removing try_move_mult_to_index
on trunk which has some fallout that I have fixed and some
fallout that should be addressed as followup. The patch
contains three new testcases from PR19807 we didn't add
and for which we regressed two with 4.8 already (-2 and -3)
and they still fail after the patch.
Patch 2 is bootstrapped and tested on x86_64-unknown-linux-gnu,
patch 1 is in testing.
I have a strong preference to have patch 2 on trunk.
Any preferences for the branches?
Thanks,
Richard.
2014-09-04 Richard Biener <rguenther@suse.de>
PR middle-end/63148
* fold-const.c (fold_plusminus_mult_expr): Avoid case
producing invalid array indexes when the multiplication
is stripped.
* gcc.dg/vect/pr63148.c: New testcase.