Patchwork Conservative alignment tracking (2nd try)

login
register
mail settings
Submitter Jakub Jelinek
Date Aug. 12, 2010, 1:42 p.m.
Message ID <20100812134210.GN702@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/61592/
State New
Headers show

Comments

Jakub Jelinek - Aug. 12, 2010, 1:42 p.m.
On Thu, Aug 12, 2010 at 06:38:25AM -0700, H.J. Lu wrote:
> On Wed, Aug 11, 2010 at 5:32 AM, Richard Guenther <rguenther@suse.de> wrote:
> It breaks bootstrap on Linux/i386:
> 
> ../../src-trunk/gcc/builtins.c: In function 'fold_builtin_memory_op':
> ../../src-trunk/gcc/builtins.c:8402:9: error: comparison between
> signed and unsigned integer expressions [-Werror=sign-compare]

Here is a fix I've bootstrapped on i686-linux (32-bit HWI).  Ok?

2010-08-12  Jakub Jelinek  <jakub@redhat.com>

	* builtins.c (fold_builtin_memory_op): Avoid -Wsign-compare
	warning.



	Jakub
H.J. Lu - Aug. 12, 2010, 1:46 p.m.
On Thu, Aug 12, 2010 at 6:42 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Aug 12, 2010 at 06:38:25AM -0700, H.J. Lu wrote:
>> On Wed, Aug 11, 2010 at 5:32 AM, Richard Guenther <rguenther@suse.de> wrote:
>> It breaks bootstrap on Linux/i386:
>>
>> ../../src-trunk/gcc/builtins.c: In function 'fold_builtin_memory_op':
>> ../../src-trunk/gcc/builtins.c:8402:9: error: comparison between
>> signed and unsigned integer expressions [-Werror=sign-compare]
>
> Here is a fix I've bootstrapped on i686-linux (32-bit HWI).  Ok?
>
> 2010-08-12  Jakub Jelinek  <jakub@redhat.com>
>
>        * builtins.c (fold_builtin_memory_op): Avoid -Wsign-compare
>        warning.
>
> --- gcc/builtins.c.jj   2010-08-12 14:07:37.000000000 +0200
> +++ gcc/builtins.c      2010-08-12 14:41:39.740220087 +0200
> @@ -8399,7 +8399,7 @@ fold_builtin_memory_op (location_t loc,
>          if (readonly_data_expr (src)
>              || (host_integerp (len, 1)
>                  && (MIN (src_align, dest_align) / BITS_PER_UNIT
> -                     >= tree_low_cst (len, 1))))
> +                     >= (unsigned HOST_WIDE_INT) tree_low_cst (len, 1))))
>            {
>              tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
>              if (!fn)
>
>
>        Jakub
>

src_align and dest_align are unsigned int:

     unsigned int src_align, dest_align;

Can we cast it to unsigned int?
Richard Guenther - Aug. 12, 2010, 1:49 p.m.
On Thu, 12 Aug 2010, Jakub Jelinek wrote:

> On Thu, Aug 12, 2010 at 06:38:25AM -0700, H.J. Lu wrote:
> > On Wed, Aug 11, 2010 at 5:32 AM, Richard Guenther <rguenther@suse.de> wrote:
> > It breaks bootstrap on Linux/i386:
> > 
> > ../../src-trunk/gcc/builtins.c: In function 'fold_builtin_memory_op':
> > ../../src-trunk/gcc/builtins.c:8402:9: error: comparison between
> > signed and unsigned integer expressions [-Werror=sign-compare]
> 
> Here is a fix I've bootstrapped on i686-linux (32-bit HWI).  Ok?

Counts as obvious (or a similar patch to use TREE_INT_CST_LOW).

Richard.

> 2010-08-12  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* builtins.c (fold_builtin_memory_op): Avoid -Wsign-compare
> 	warning.
> 
> --- gcc/builtins.c.jj	2010-08-12 14:07:37.000000000 +0200
> +++ gcc/builtins.c	2010-08-12 14:41:39.740220087 +0200
> @@ -8399,7 +8399,7 @@ fold_builtin_memory_op (location_t loc, 
>  	  if (readonly_data_expr (src)
>  	      || (host_integerp (len, 1)
>  		  && (MIN (src_align, dest_align) / BITS_PER_UNIT
> -		      >= tree_low_cst (len, 1))))
> +		      >= (unsigned HOST_WIDE_INT) tree_low_cst (len, 1))))
>  	    {
>  	      tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
>  	      if (!fn)
> 
> 
> 	Jakub
> 
>
H.J. Lu - Jan. 13, 2011, 6:25 p.m.
On Thu, Aug 12, 2010 at 6:42 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Aug 12, 2010 at 06:38:25AM -0700, H.J. Lu wrote:
>> On Wed, Aug 11, 2010 at 5:32 AM, Richard Guenther <rguenther@suse.de> wrote:
>> It breaks bootstrap on Linux/i386:
>>
>> ../../src-trunk/gcc/builtins.c: In function 'fold_builtin_memory_op':
>> ../../src-trunk/gcc/builtins.c:8402:9: error: comparison between
>> signed and unsigned integer expressions [-Werror=sign-compare]
>
> Here is a fix I've bootstrapped on i686-linux (32-bit HWI).  Ok?
>
> 2010-08-12  Jakub Jelinek  <jakub@redhat.com>
>
>        * builtins.c (fold_builtin_memory_op): Avoid -Wsign-compare
>        warning.
>
> --- gcc/builtins.c.jj   2010-08-12 14:07:37.000000000 +0200
> +++ gcc/builtins.c      2010-08-12 14:41:39.740220087 +0200
> @@ -8399,7 +8399,7 @@ fold_builtin_memory_op (location_t loc,
>          if (readonly_data_expr (src)
>              || (host_integerp (len, 1)
>                  && (MIN (src_align, dest_align) / BITS_PER_UNIT
> -                     >= tree_low_cst (len, 1))))
> +                     >= (unsigned HOST_WIDE_INT) tree_low_cst (len, 1))))
>            {
>              tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
>              if (!fn)
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47280

Patch

--- gcc/builtins.c.jj	2010-08-12 14:07:37.000000000 +0200
+++ gcc/builtins.c	2010-08-12 14:41:39.740220087 +0200
@@ -8399,7 +8399,7 @@  fold_builtin_memory_op (location_t loc, 
 	  if (readonly_data_expr (src)
 	      || (host_integerp (len, 1)
 		  && (MIN (src_align, dest_align) / BITS_PER_UNIT
-		      >= tree_low_cst (len, 1))))
+		      >= (unsigned HOST_WIDE_INT) tree_low_cst (len, 1))))
 	    {
 	      tree fn = implicit_built_in_decls[BUILT_IN_MEMCPY];
 	      if (!fn)