This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/37242] missed FRE opportunity because of signedness of addition
- From: "rguenther at suse dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Aug 2008 09:40:52 -0000
- Subject: [Bug tree-optimization/37242] missed FRE opportunity because of signedness of addition
- References: <bug-37242-7849@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #7 from rguenther at suse dot de 2008-08-27 09:40 -------
Subject: Re: missed FRE opportunity because of
signedness of addition
On Wed, 27 Aug 2008, bonzini at gnu dot org wrote:
>
>
> ------- Comment #4 from bonzini at gnu dot org 2008-08-27 06:41 -------
> Minimized testcase:
>
> int m(int *y, int x)
> {
> int a = y[x + 1];
> int b = y[++x];
> return a - b;
> }
>
> should be optimized to "return 0"
Because fold folds (unsigned)(x + 1) to (unsigned)x + 1 but doesn't
touch (unsigned) ++x which gets gimplified to a signed addition.
Richard.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37242