This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
BImode and STORE_VALUE_FLAG
- From: "Paulo Matos" <pmatos at broadcom dot com>
- To: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Fri, 3 May 2013 12:49:14 +0000
- Subject: BImode and STORE_VALUE_FLAG
Hello,
It seems to me there's a bug in simplify_const_relational_operation:simplify-rtx.c.
If you set STORE_VALUE_FLAG to -1, if you get to simplify_const_relational_operation with code: NE, mode: BImode, op0: reg, op1: const_int 0, then you end up in line 4717 calling get_mode_bounds.
get_mode_bounds will unfortunately return min:0, max:-1 for BImode and GCC proceeds to compare val which is 0 using:
/* x != y is always true for y out of range. */
if (val < mmin || val > mmax)
return const_true_rtx;
This simplifies the comparison to const_true_rtx in the case STORE_FLAG_VALUE is -1. This seems flawed.
Unless there's some background reason for this to happen this seems like a bug. BImode is a two value mode: 0 or STORE_FLAG_VALUE (according to trunc_int_to_mode), therefore there are really no bounds and these comparisons in simplify_const_relational_operation should take special care if dealing with BImode. Also, having max < min is strange at best and I can imagine it can result in pretty strange behaviour if a developer assumes max >= min, as usual.
I am interested in comments to this piece of code. I am happy to patch simplify_const_relational_operation if you agree with what I said.
Cheers,
Paulo Matos