[PATCH] Fix PR39715 (Thumb pessimization)

Paolo Bonzini bonzini@gnu.org
Sun Aug 2 00:48:00 GMT 2009


>> Index: gcc/simplify-rtx.c
>> ===================================================================
>> --- gcc/simplify-rtx.c	(branch cond-optab2)
>> +++ gcc/simplify-rtx.c	(working copy)
>> @@ -3990,6 +3990,49 @@ simplify_relational_operation_1 (enum rt
>>   				    simplify_gen_binary (XOR, cmp_mode,
>>   							 XEXP (op0, 1), op1));
>>
>> +  /* Look for useless extensions of a subreg, if the extension
>> +     is from the same mode as the subreg.  */
>> +  if (op0code == SIGN_EXTEND
>> +&&  GET_CODE (XEXP (op0, 0)) == SUBREG
>> +&&  subreg_lowpart_p (XEXP (op0, 0))
>> +&&  GET_MODE (op0) == GET_MODE (SUBREG_REG (XEXP (op0, 0)))
>> +&&  num_sign_bit_copies (SUBREG_REG (XEXP (op0, 0)), GET_MODE (op0))
>> +>  (unsigned) (GET_MODE_BITSIZE (GET_MODE (op0))
>> +		       - GET_MODE_BITSIZE (GET_MODE (XEXP (op0, 0)))))
>> +    return simplify_gen_relational (code, mode, cmp_mode,
>> +				    SUBREG_REG (XEXP (op0, 0)), op1);
>> +
>> +  if (GET_CODE (op1) == SIGN_EXTEND
>> +&&  GET_CODE (XEXP (op1, 0)) == SUBREG
>> +&&  subreg_lowpart_p (XEXP (op0, 0))
>> +&&  GET_MODE (op1) == GET_MODE (SUBREG_REG (XEXP (op1, 0)))
>> +&&  num_sign_bit_copies (SUBREG_REG (XEXP (op1, 0)), GET_MODE (op1))
>> +>  (unsigned) (GET_MODE_BITSIZE (GET_MODE (op1))
>> +		       - GET_MODE_BITSIZE (GET_MODE (XEXP (op1, 0)))))
>> +    return simplify_gen_relational (code, mode, cmp_mode,
>> +				    op0, SUBREG_REG (XEXP (op1, 0)));
>
> These seem to be true even without the enclosing comparison:

Yes, you're right.

> Doesn't my changes to simplify_shift_const_1 in combine fix this?

Maybe, are they committed already?  Definitely you need the 
simplify_comparison part.  It would be okay for me to get separate 
approval for that and look into your changes?

Paolo



More information about the Gcc-patches mailing list