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

[Bug rtl-optimization/66156] [msp430] wrong code generated with -O2 -mlarge (zero extension HI -> SI)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66156

Nick Clifton <nickc at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nickc at redhat dot com

--- Comment #1 from Nick Clifton <nickc at redhat dot com> ---
Hi Ronald,

  What's going on is that this is a reload bug.  Reload wants to extend r42
into r43 (or rather r12 into r10) and it is assuming that the zero_extendhisi
pattern will do this.  Unfortunately it does not, it only extends in place, and
so an extra move is required to make the conversion complete.  Reload generates
this extra move, but of course it is too late, r13 has already been clobbered.

  Not being a reload guru, I have decided to take the easy way out and extend
the zero_extendhisi2 pattern so that it can cope with moving the value whilst
extending it.  This works, although it does still leave a potential bug in
reload for other targets.  But for now it is the simplest solution.  So I am
going to apply this patch to the msp430 sources.  Please let me know if you
have any problems with it.

Cheers
  Nick

Index: gcc/config/msp430/msp430.md
===================================================================
--- gcc/config/msp430/msp430.md (revision 223348)
+++ gcc/config/msp430/msp430.md (working copy)
@@ -588,10 +588,12 @@
 ;; patterns.  Doing these manually allows for alternate optimization
 ;; paths.
 (define_insn "zero_extendhisi2"
-  [(set (match_operand:SI 0 "nonimmediate_operand" "=rm")
-       (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0")))]
+  [(set (match_operand:SI 0 "nonimmediate_operand" "=rm,r")
+       (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "0,r")))]
   "msp430x"
-  "MOV.W\t#0,%H0"
+  "@
+  MOV.W\t#0,%H0
+  MOV.W\t%1,%L0 { MOV.W\t#0,%H0"
 )

 (define_insn "zero_extendhisipsi2"


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