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: Commit: MSP430: Pass -md on to assembler


On Sep 23, 2013, at 8:24 AM, nick clifton <nickc@redhat.com> wrote:
>> +(define_insn "extendpsisi2"
>> +  [(set (match_operand:SI 0 "nonimmediate_operand" "=r")
>> +	(sign_extend:SI (match_operand:PSI 1 "nonimmediate_operand" "0")))]
>> +  "TARGET_LARGE"
>> +  "# extend psi to si in %0"
>> +)
>> +
>>  ;; Look for cases where integer/pointer conversions are suboptimal due
> 
> Works like a charm.  The strange thing though is that the pattern never has to generate any code.  (I added a gcc_unreachable() to detect if the pattern was ever used to generate assembler).

> I must say though, it seems wrong to have to provide a sign-extend pointer pattern when pointers (on the MSP430) are unsigned.

Agreed.  If we instead ask, is it sane for gcc to ever want to signed extend in this case, the answer appears to be no.  Why does it, ptr_mode is SImode, and expand_builtin_next_arg is used to perform the addition in this mode.  It 'just' knows that is can be signed extended… and just does it that way.  This seems like it is wrong.

Index: builtins.c
===================================================================
--- builtins.c	(revision 202634)
+++ builtins.c	(working copy)
@@ -4094,7 +4094,7 @@ expand_builtin_next_arg (void)
   return expand_binop (ptr_mode, add_optab,
 		       crtl->args.internal_arg_pointer,
 		       crtl->args.arg_offset_rtx,
-		       NULL_RTX, 0, OPTAB_LIB_WIDEN);
+		       NULL_RTX, POINTERS_EXTEND_UNSIGNED > 0, OPTAB_LIB_WIDEN);
 }
 
 /* Make it easier for the backends by protecting the valist argument

would fix this problem.  If this is done, the unmodified test case then doesn't abort.  Arguably, the extension should be done as the port directs.  It isn't clear to me why they do not.

Ok?


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