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]

Re: [2/11] Neater tests for signbits


On 07/05/11 21:08, Richard Henderson wrote:
> On 07/01/2011 10:29 AM, Bernd Schmidt wrote:
>> 	* cse.c (find_comparison_args): Use val_mode_signbit_set_p.
>> 	* simplify-rtx.c (mode_signbit_p): Use GET_MODE_PRECISION.
>> 	(val_mode_signbit_p, val_mode_signbit_set_p): New functions.
>> 	(simplify_const_unary_operation, simplify_binary_operation_1,
>> 	simplify_const_binary_operation,
>> 	simplify_const_relational_operation): Use them.  Use
>> 	GET_MODE_MASK for masking and sign-extensions.
>> 	* combine.c (set_nonzero_bits_and_sign_copies, simplify_set,
>> 	combine_simplify_rtx, force_to_mode, reg_nonzero_bits_for_combine,
>> 	simplify_shift_const_1, simplify_comparison): Likewise.
>> 	* expr.c (convert_modes): Likewise.
>> 	* rtlanal.c (nonzero_bits1, canonicalize_condition): Likewise.
>> 	* expmed.c (emit_cstore, emit_store_flag_1, emit_store_flag):
>> 	Likewise.
>> 	* rtl.h (val_mode_signbit_p, val_mode_signbit_set_p): Declare.
> 
> Ok, but,
> 
>>  	  /* We must sign or zero-extend in this case.  Start by
>>  	     zero-extending, then sign extend if we need to.  */
>> -	  val &= ((HOST_WIDE_INT) 1 << width) - 1;
>> +	  val &= GET_MODE_MASK (oldmode);
>>  	  if (! unsignedp
>> -	      && (val & ((HOST_WIDE_INT) 1 << (width - 1))))
>> -	    val |= (HOST_WIDE_INT) (-1) << width;
>> +	      && val_signbit_known_set_p (oldmode, val))
>> +	    val |= ~GET_MODE_MASK (oldmode);
>>  
>>  	  return gen_int_mode (val, mode);
> 
> Shouldn't that sign-extension already be done by gen_int_mode?

I think that's a different case than the simplify_rtx one in patch #3.
Here, we're extending from oldmode, while gen_int_mode takes care of the
extension for mode.

Thanks for the reviews!


Bernd


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