This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: BImode and STORE_VALUE_FLAG
- From: Mikael Pettersson <mikpe at it dot uu dot se>
- To: "Paulo Matos" <pmatos at broadcom dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Sat, 4 May 2013 12:50:46 +0200
- Subject: Re: BImode and STORE_VALUE_FLAG
- References: <19EB96622A777C4AB91610E763265F461C522A at SJEXCHMB14 dot corp dot ad dot broadcom dot com>
On Fri, 3 May 2013 12:49:14 +0000, Paulo Matos <pmatos@broadcom.com> wrote:
> 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
I can't comment on the code in question, but the backend for m68k may be affected
since it defines STORE_FLAG_VALUE as -1. Do you have a testcase that would cause
wrong code, or a patch to cure the issue? I'd be happy to do some testing on
m68k-linux.
/Mikael