diff mbox

[committed,SH] Fix PR target/64833

Message ID 20150701.100434.352025247.kkojima@rr.iij4u.or.jp
State New
Headers show

Commit Message

Kaz Kojima July 1, 2015, 1:04 a.m. UTC
The attached patch is to fix PR target/64833 which is a 4.9/5/6
regression.  The target reorg may replace casesi_worker_1 insn
with casesi_worker_2 with a temporary wrong length for PIC.
It can result the wrong position of the constant pool.  See PR
target/64833 for details.
The patch set the length of casesi_worker_1 to 8 for PIC so to
avoid that misplacement of the constant pool.  It's tested on
sh4-unknown-linux-gnu.  Committed on trunk.  I'll backport it
to 5 and 4.9.

Regards,
	kaz
--
2015-06-30  Kaz Kojima  <kkojima@gcc.gnu.org>

	PR target/64833
	* config/sh/sh.md (casesi_worker_1): Set length to 8 when
	flag_pic is set.
diff mbox

Patch

diff --git a/config/sh/sh.md b/config/sh/sh.md
index 35113c0..5c8d306 100644
--- a/config/sh/sh.md
+++ b/config/sh/sh.md
@@ -11344,6 +11344,8 @@  label:
     LABEL_NUSES (operands[2])++;
 })
 
+;; This may be replaced with casesi_worker_2 in sh_reorg for PIC.
+;; The insn length is set to 8 for that case.
 (define_insn "casesi_worker_1"
   [(set (match_operand:SI 0 "register_operand" "=r,r")
 	(unspec:SI [(reg:SI R0_REG)
@@ -11375,7 +11377,9 @@  label:
       gcc_unreachable ();
     }
 }
-  [(set_attr "length" "4")])
+  [(set_attr_alternative "length"
+     [(if_then_else (match_test "flag_pic") (const_int 8) (const_int 4))
+      (if_then_else (match_test "flag_pic") (const_int 8) (const_int 4))])])
 
 (define_insn "casesi_worker_2"
   [(set (match_operand:SI 0 "register_operand" "=r,r")