[patch RFA] SH: Fix build failure for sh64-*-linux-gnu

Kaz Kojima kkojima@rr.iij4u.or.jp
Wed Jan 4 14:24:00 GMT 2006


Joern RENNECKE <joern.rennecke@st.com> wrote:
> This is not actually specific for PIC.  Neither does it seem necessary...
[snip]
> ... since you can you 's' for the constraint.  (In principle 'i' should 
> work as well, but
> we shouldn't be generating out-of-range numeric constants in the first 
> place.)
>
> It also seems prudent to remove the generation of the sign_extend / 
> truncate steps
> from gen_movsi_const / gen_movdi_const / gen_movdi_const_32bit .

I've attached the revised patch.  A few new insns are needed to remove
extend/truncate steps form movdi_const.
It's tested on sh4-unknown-linux-gnu, x86 cross sh64-unknown-linux-gnu
and x86 cross sh64-elf.

> I don't see why this is connected to the extend/truncate elimination.  
> Do we actually
> end up assuming the value is smaller than it is, and thus won't do the 
> transformation
> when we know the actual size?

I should be more explicit about it.  In that case, it looks that
the new optimization reduces

  (zero_extend:SI (truncate:HI (const:SI (sign_extend:SI (truncate:HI (const ...))))))

to

  (zero_extend:SI (truncate:HI (const ...)))

where the inner const is generated by gen_symGOTPLT2reg with VOIDmode
and this VOIDmode const is caught by the check in simplify_subreg.
It'd be a logically separated issue as you say but the extend/truncate
elimination reveals this latent problem.  Should it be submited as an
independent patch?

> In general, it is desirable (and often necessary) to have a mode on 
> every const and unspec
> used for a data item (I mean an actual rtl data item - matching patterns 
> often have to leave
> out the mode).  We don't always do this because of the awkwardness of 
> putting
> Pmode in an expander.  Still, I would prefer to fix this in the 
> sym2GOTPLT expander -
> I suppose the only sane way to do this is making it a C function.  
> You'll will have to watch
> out if this disrupts any insn, combiner/splitter or peephole patterns, 
> though.

Agreed.

Regards,
	kaz
--
2006-01-04  Kaz Kojima  <kkojima@gcc.gnu.org>

	* config/sh/sh.md (shori_media): Add s constraint case.
	(shori_media_si): Likewise.
	(movsi_const): Remove the generation of the sign_extend and
	truncate steps.
	(movdi_const_di, movdi_const_32bit): Likewise.
	(shori_media_midlow): New insn.
	(shori_media_midhigh, shori_media_high): Likewise.
	(symGOTPLT2reg): Set GOTPLT const to Pmode.

diff -uprN ORIG/trunk/gcc/config/sh/sh.md LOCAL/trunk/gcc/config/sh/sh.md
--- ORIG/trunk/gcc/config/sh/sh.md	2005-11-25 06:59:17.000000000 +0900
+++ LOCAL/trunk/gcc/config/sh/sh.md	2006-01-04 10:57:07.000000000 +0900
@@ -1,6 +1,6 @@
 ;;- Machine description for Renesas / SuperH SH.
 ;;  Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-;;  2003, 2004, 2005 Free Software Foundation, Inc.
+;;  2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 ;;  Contributed by Steve Chamberlain (sac@cygnus.com).
 ;;  Improved by Jim Wilson (wilson@cygnus.com).
 
@@ -4906,9 +4906,7 @@ label:
 	(ior:SI (ashift:SI (match_dup 0) (const_int 16))
 		(zero_extend:SI
 		 (truncate:HI
-		  (const:SI
-		   (sign_extend:SI
- 		    (truncate:HI (match_dup 1))))))))]
+		  (match_dup 1)))))]
   "TARGET_SHMEDIA && reload_completed
    && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
   "
@@ -5351,30 +5349,21 @@ label:
 	(ior:DI (ashift:DI (match_dup 0) (const_int 16))
 		(zero_extend:DI
 		 (truncate:HI
-		  (const:DI
-		   (sign_extend:DI
-		    (truncate:HI
-		     (ashiftrt:SI
-		      (match_dup 1)
-		      (const_int 32)))))))))
+		  (ashiftrt:DI
+		   (match_dup 1)
+		   (const_int 32))))))
    (set (match_dup 0)
 	(ior:DI (ashift:DI (match_dup 0) (const_int 16))
 		(zero_extend:DI
 		 (truncate:HI
-		  (const:DI
-		   (sign_extend:DI
-		    (truncate:HI
-		     (ashiftrt:SI
-		      (match_dup 1)
-		      (const_int 16)))))))))
+		  (ashiftrt:DI
+		   (match_dup 1)
+		   (const_int 16))))))
    (set (match_dup 0)
 	(ior:DI (ashift:DI (match_dup 0) (const_int 16))
 		(zero_extend:DI
 		 (truncate:HI
-		  (const:DI
-		   (sign_extend:DI
-		    (truncate:HI
-		     (match_dup 1))))))))]
+		  (match_dup 1)))))]
   "TARGET_SHMEDIA64 && reload_completed
    && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
   "
@@ -5393,10 +5382,7 @@ label:
 	(ior:DI (ashift:DI (match_dup 0) (const_int 16))
 		(zero_extend:DI
 		 (truncate:HI
-		  (const:DI
-		   (sign_extend:DI
-		    (truncate:HI
-		     (match_dup 1))))))))]
+		  (match_dup 1)))))]
   "TARGET_SHMEDIA32 && reload_completed
    && MOVI_SHORI_BASE_OPERAND_P (operands[1])"
   "
@@ -5563,27 +5549,69 @@ label:
 }")
 
 (define_insn "shori_media"
-  [(set (match_operand:DI 0 "ext_dest_operand" "=r,r")
-	(ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0,0")
+  [(set (match_operand:DI 0 "ext_dest_operand" "=r,r,r")
+	(ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0,0,0")
 			   (const_int 16))
 		(zero_extend:DI
 		 (truncate:HI
-		  (match_operand:DI 2 "immediate_operand" "I16C16,nF")))))]
+		  (match_operand:DI 2 "immediate_operand" "I16C16,s,nF")))))]
   "TARGET_SHMEDIA && (reload_completed || arith_reg_dest (operands[0], DImode))"
   "@
 	shori	%u2, %0
+	shori	((%u2) & 65535), %0
 	#"
-  [(set_attr "type" "arith_media,*")])
+  [(set_attr "type" "arith_media,arith_media,*")])
+
+(define_insn "shori_media_midlow"
+  [(set (match_operand:DI 0 "ext_dest_operand" "=r")
+	(ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
+			   (const_int 16))
+		(zero_extend:DI
+		 (truncate:HI
+		  (ashiftrt:DI
+		    (match_operand:DI 2 "immediate_operand" "s")
+		    (const_int 16))))))]
+  "TARGET_SHMEDIA && (reload_completed || arith_reg_dest (operands[0], DImode))"
+  "shori	(((%u2) >> 16) & 65535), %0"
+  [(set_attr "type" "arith_media")])
+
+(define_insn "shori_media_midhigh"
+  [(set (match_operand:DI 0 "ext_dest_operand" "=r")
+	(ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
+			   (const_int 16))
+		(zero_extend:DI
+		 (truncate:HI
+		  (ashiftrt:DI
+		    (match_operand:DI 2 "immediate_operand" "s")
+		    (const_int 32))))))]
+  "TARGET_SHMEDIA && (reload_completed || arith_reg_dest (operands[0], DImode))"
+  "shori	(((%u2) >> 32) & 65535), %0"
+  [(set_attr "type" "arith_media")])
+
+(define_insn "shori_media_high"
+  [(set (match_operand:DI 0 "ext_dest_operand" "=r")
+	(ior:DI (ashift:DI (match_operand:DI 1 "arith_reg_operand" "0")
+			   (const_int 16))
+		(zero_extend:DI
+		 (truncate:HI
+		  (ashiftrt:DI
+		    (match_operand:DI 2 "immediate_operand" "s")
+		    (const_int 48))))))]
+  "TARGET_SHMEDIA && (reload_completed || arith_reg_dest (operands[0], DImode))"
+  "shori	(((%u2) >> 48) & 65535), %0"
+  [(set_attr "type" "arith_media")])
 
 (define_insn "*shori_media_si"
-  [(set (match_operand:SI 0 "arith_reg_dest" "=r")
-	(ior:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0")
+  [(set (match_operand:SI 0 "arith_reg_dest" "=r,r")
+	(ior:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "0,0")
 			   (const_int 16))
 		(zero_extend:SI
 		 (truncate:HI
-		  (match_operand:SI 2 "immediate_operand" "I16C16")))))]
+		  (match_operand:SI 2 "immediate_operand" "I16C16,s")))))]
   "TARGET_SHMEDIA"
-  "shori	%u2, %0")
+  "@
+	shori	%u2, %0
+	shori	((%u2) & 65535), %0")
 
 (define_expand "movdi"
   [(set (match_operand:DI 0 "general_movdst_operand" "")
@@ -8325,7 +8353,12 @@ label:
   ""
   "
 {
-  emit_insn (gen_symGOT_load (operands[0], gen_sym2GOTPLT (operands[1])));
+  rtx pltsym;
+
+  pltsym = gen_sym2GOTPLT (operands[1]);
+  PUT_MODE (pltsym, Pmode);
+  emit_insn (gen_symGOT_load (operands[0], pltsym));
+
   DONE;
 }")
 



More information about the Gcc-patches mailing list