[patch committed] SH: Fix PR target/32506

Kaz Kojima kkojima@rr.iij4u.or.jp
Tue Jul 3 05:15:00 GMT 2007


A simple testcase

unsigned int
foo (unsigned int n, unsigned d)
{
  return n % d;
}

fails with -O -fpic -m5-64media-nofpu on all 4.x compilers for
sh64-unknown-linux-gnu.  Since it doesn't fail on 3.4.6, this
is a 4.1/4.2/4.3 regression.
udivsi3_i1_media insn uses the predicate target_operand which
permits symbol_ref.  It's reloaded with a target register and,
in PIC case, legitimize_pic_address tries to use this target
register to compute the PIC address.
This results the ICE because target registers can't be use as
generic address registers.  The attached patch is to avoid this.
It's tested with x86-linux cross sh64-unknown-linux-gnu build
and regtested on sh64-unknown-linux-gnu and sh64-unknown-elf
with no new failures.  Committed on trunk.  I'll backport it
to 4.1/4.2 after successful tests on the branches.

Regards,
	kaz 
--
2007-07-03  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/32506
	* config/sh/sh.md (udivsi3_i1_media): Use target_reg_operand
	predicate instead of target_operand.
	(divsi3_i1_media, divsi3_media_2): Likewise.

--- ORIG/trunk/gcc/config/sh/sh.md	Thu Jun 28 08:15:35 2007
+++ LOCAL/trunk/gcc/config/sh/sh.md	Mon Jul  2 21:44:49 2007
@@ -1765,7 +1765,7 @@
    (clobber (reg:DI TR0_REG))
    (clobber (reg:DI TR1_REG))
    (clobber (reg:DI TR2_REG))
-   (use (match_operand 1 "target_operand" "b"))]
+   (use (match_operand 1 "target_reg_operand" "b"))]
   "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)"
   "blink	%1, r18"
   [(set_attr "type" "sfunc")
@@ -1962,7 +1962,7 @@
    (clobber (reg:SI R20_REG))
    (clobber (reg:SI R21_REG))
    (clobber (reg:SI TR0_REG))
-   (use (match_operand 1 "target_operand" "b"))]
+   (use (match_operand 1 "target_reg_operand" "b"))]
   "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)"
   "blink	%1, r18"
   [(set_attr "type" "sfunc")])
@@ -1976,7 +1976,7 @@
    (clobber (reg:SI R21_REG))
    (clobber (reg:SI TR0_REG))
    (use (reg:SI R20_REG))
-   (use (match_operand 1 "target_operand" "b"))]
+   (use (match_operand 1 "target_reg_operand" "b"))]
   "TARGET_SHMEDIA && (! TARGET_SHMEDIA_FPU || ! TARGET_DIVIDE_FP)"
   "blink	%1, r18"
   [(set_attr "type" "sfunc")])



More information about the Gcc-patches mailing list