This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Bootstrap broken on PPC


> Actually the warning is correct, result is not initialized at all for 
> some cases.
> 
> From builtins.t03.original:
>             case 345u:
>             case 346u:
>             case 347u:
>                if (hi != 0l)
>                   result = width - (floor_log2_wide(hi)) - 33l;
>                else if (lo != 0ul)
>                   result = width - (floor_log2_wide(lo)) - 1l;
>                else if (0)
>                   result = width;
> 
> Looks like the test:
>           else if (! CLZ_DEFINED_VALUE_AT_ZERO (TYPE_MODE (type), 
> result))
>             result = width;
> gets fold into
> 	else if (0)
> 		result = width;
> 
> 
> Note CLZ_DEFINED_VALUE_AT_ZERO is defined as:
> /* The cntlzw and cntlzd instructions return 32 and 64 for input of 
> zero.  */
> #define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) \
>   ((VALUE) = ((MODE) == SImode ? 32 : 64))
> 
> So the setting for result is not done.
> 
> Here is a simple testcase:
> int t(int m)
> {
>   int value;
>   if (!(value = (m?1:2)))
>     value = 0;
>   return value;
> }
Thanks! I was looking into this for almost hour already and didn't
noticed that.  I am commiting the obvious fix attached.

2003-11-09  Jan Hubicka  <jh@suse.cz>
	* fold-const.c (fold_relational_const): Check for side effects.
Index: fold-const.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fold-const.c,v
retrieving revision 1.213.2.59
diff -c -3 -p -r1.213.2.59 fold-const.c
*** fold-const.c	8 Nov 2003 18:22:22 -0000	1.213.2.59
--- fold-const.c	9 Nov 2003 02:32:12 -0000
*************** fold_relational_const (enum tree_code co
*** 8893,8902 ****
  			   0);
      }
  
!   else if (code == EQ_EXPR
             && integer_zerop (op1) && tree_expr_nonzero_p (op0))
      tem = build_int_2 (0, 0);
!   else if (code == NE_EXPR
             && integer_zerop (op1) && tree_expr_nonzero_p (op0))
      tem = build_int_2 (1, 0);
  
--- 8893,8902 ----
  			   0);
      }
  
!   else if (code == EQ_EXPR && !TREE_SIDE_EFFECTS (op0)
             && integer_zerop (op1) && tree_expr_nonzero_p (op0))
      tem = build_int_2 (0, 0);
!   else if (code == NE_EXPR && !TREE_SIDE_EFFECTS (op0)
             && integer_zerop (op1) && tree_expr_nonzero_p (op0))
      tem = build_int_2 (1, 0);
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]