This is the mail archive of the gcc-patches@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]

RFA: Fix value-prof.c call to build_int_cst_wide


Dale Johannesen <dalej@apple.com> writes:
> On Apr 6, 2005, at 3:59 PM, Richard Sandiford wrote:
>> [ Dale: I notice that your recent value-prof.c patch uses 0xffffffffull
>>   in a call to build_int_cst_wide.  I guess that needs to be changed
>>   to be compatible with C90. ]
>>
>> -  tree_val = build_int_cst_wide (GCOV_TYPE_NODE, val & 0xffffffffull,
>> val >> 32);
>> +  tree_val = build_int_cst_wide (get_gcov_type (),
>> +				 val & 0xffffffffull, val >> 32);
>
> As well as breaking when sizeof(gcov_type) != 64.

or when HOST_BITS_PER_WIDE_INT != 32 ;)  (Because build_int_cst_wide
expects HOST_WIDE_INTs.)

> Memory is stirring; I never liked this bit, and it's one reason I
> never tried to put this in mainline myself.  However I don't know how
> to do this in conformant fashion.

Does the patch below look OK?  The cast in the second argument isn't
strictly needed but I think it helps to document what's going on.

Bootstrapped & regression tested on i686-pc-linux-gnu.  OK for mainline?

Richard


	* value-prof.c (tree_divmod_fixed_value_transform): Fix arguments
	to build_int_cst_wide.

Index: value-prof.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/value-prof.c,v
retrieving revision 1.23
diff -u -p -F^\([(a-zA-Z0-9_]\|#define\) -r1.23 value-prof.c
--- value-prof.c	6 Apr 2005 22:50:29 -0000	1.23
+++ value-prof.c	9 Apr 2005 12:00:16 -0000
@@ -1243,7 +1243,8 @@ tree_divmod_fixed_value_transform (tree 
   prob = (count * REG_BR_PROB_BASE + all / 2) / all;
 
   tree_val = build_int_cst_wide (get_gcov_type (),
-				 val & 0xffffffffull, val >> 32);
+				 (unsigned HOST_WIDE_INT) val,
+				 val >> (HOST_BITS_PER_WIDE_INT - 1) >> 1);
   result = tree_divmod_fixed_value (stmt, op, op1, op2, tree_val, prob, count, all);
 
   TREE_OPERAND (modify, 1) = result;


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