On 10/20/2015 10:33 AM, Eric Botcazou wrote:
Hi,
this test started to fail recently as the result of the work of Richard S.,
but the underlying issue had been latent for a long time. It boils down to
this excerpt from the VRP1 dump file:
Found new range for _9: [0, 12]
marking stmt to be not simulated again
Visiting statement:
_3 = _9 %[fl] _11;
Found new range for _3: [0, +INF]
which is plain wrong since the sign of FLOOR_MOD_EXPR is the sign of the
divisor and not that of the dividend (the latter is for TRUNC_MOD_EXPR).
I have attached a fix for mainline and another one for the 4.9/5 branches.
Tested on x86_64-suse-linux, OK for all active branches?
2015-10-20 Eric Botcazou <ebotca...@adacore.com>
* fold-const.c (tree_binary_nonnegative_warnv_p) <FLOOR_MOD_EXPR>:
Recurse on operand #1 instead of operand #0.
<CEIL_MOD_EXPR>: Do not recurse.
<ROUND_MOD_EXPR>: Likewise.
Isn't this a function of the language and in some cases isn't it
implementation defined (true for C/C++ until C++11)?
Even with that in mind, I think FLOOR_MOD_EXPR and TRUNC_MOD_EXPR are
more correct with your patch. I'm just not sure about CEIL & ROUND.
Jeff