Blame SOURCES/gcc48-rh1535655-4.patch

4dd737
commit 94695137d1ea3c094dd37ab5b73d66b09639f3f4
4dd737
Author: hjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>
4dd737
Date:   Tue Jan 16 11:17:49 2018 +0000
4dd737
4dd737
    HJ patch #3
4dd737
4dd737
diff --git a/gcc/config/i386/constraints.md b/gcc/config/i386/constraints.md
4dd737
index d567fd7..43faabb 100644
4dd737
--- a/gcc/config/i386/constraints.md
4dd737
+++ b/gcc/config/i386/constraints.md
4dd737
@@ -135,7 +135,8 @@
4dd737
 
4dd737
 (define_constraint "w"
4dd737
   "@internal Call memory operand."
4dd737
-  (and (not (match_test "TARGET_X32"))
4dd737
+  (and (not (match_test "ix86_indirect_branch_register"))
4dd737
+       (not (match_test "TARGET_X32"))
4dd737
        (match_operand 0 "memory_operand")))
4dd737
 
4dd737
 ;; Integer constant constraints.
4dd737
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
4dd737
index ef16cf5..228f8f6 100644
4dd737
--- a/gcc/config/i386/i386.md
4dd737
+++ b/gcc/config/i386/i386.md
4dd737
@@ -11274,7 +11274,7 @@
4dd737
   [(set (pc) (match_operand 0 "indirect_branch_operand"))]
4dd737
   ""
4dd737
 {
4dd737
-  if (TARGET_X32)
4dd737
+  if (TARGET_X32 || ix86_indirect_branch_register)
4dd737
     operands[0] = convert_memory_address (word_mode, operands[0]);
4dd737
   cfun->machine->has_local_indirect_jump = true;
4dd737
 })
4dd737
@@ -11327,7 +11327,7 @@
4dd737
 					 OPTAB_DIRECT);
4dd737
     }
4dd737
 
4dd737
-  if (TARGET_X32)
4dd737
+  if (TARGET_X32 || ix86_indirect_branch_register)
4dd737
     operands[0] = convert_memory_address (word_mode, operands[0]);
4dd737
   cfun->machine->has_local_indirect_jump = true;
4dd737
 })
4dd737
@@ -11514,7 +11514,7 @@
4dd737
 })
4dd737
 
4dd737
 (define_insn "*call_pop"
4dd737
-  [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lzm"))
4dd737
+  [(call (mem:QI (match_operand:SI 0 "call_insn_operand" "lwz"))
4dd737
 	 (match_operand 1))
4dd737
    (set (reg:SI SP_REG)
4dd737
 	(plus:SI (reg:SI SP_REG)
4dd737
@@ -11612,7 +11612,7 @@
4dd737
 
4dd737
 (define_insn "*call_value_pop"
4dd737
   [(set (match_operand 0)
4dd737
-	(call (mem:QI (match_operand:SI 1 "call_insn_operand" "lzm"))
4dd737
+	(call (mem:QI (match_operand:SI 1 "call_insn_operand" "lwz"))
4dd737
 	      (match_operand 2)))
4dd737
    (set (reg:SI SP_REG)
4dd737
 	(plus:SI (reg:SI SP_REG)
4dd737
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
4dd737
index 9dfa2cb..0a8ae8f 100644
4dd737
--- a/gcc/config/i386/i386.opt
4dd737
+++ b/gcc/config/i386/i386.opt
4dd737
@@ -654,3 +654,7 @@ Enum(indirect_branch) String(thunk-inline) Value(indirect_branch_thunk_inline)
4dd737
 
4dd737
 EnumValue
4dd737
 Enum(indirect_branch) String(thunk-extern) Value(indirect_branch_thunk_extern)
4dd737
+
4dd737
+mindirect-branch-register
4dd737
+Target Report Var(ix86_indirect_branch_register) Init(0)
4dd737
+Force indirect call and jump via register.
4dd737
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
4dd737
index 61614e1..6c7a593 100644
4dd737
--- a/gcc/config/i386/predicates.md
4dd737
+++ b/gcc/config/i386/predicates.md
4dd737
@@ -540,7 +540,8 @@
4dd737
 ;; Test for a valid operand for indirect branch.
4dd737
 (define_predicate "indirect_branch_operand"
4dd737
   (ior (match_operand 0 "register_operand")
4dd737
-       (and (not (match_test "TARGET_X32"))
4dd737
+       (and (not (match_test "ix86_indirect_branch_register"))
4dd737
+	    (not (match_test "TARGET_X32"))
4dd737
 	    (match_operand 0 "memory_operand"))))
4dd737
 
4dd737
 ;; Test for a valid operand for a call instruction.
4dd737
@@ -549,8 +550,9 @@
4dd737
   (ior (match_test "constant_call_address_operand
4dd737
 		     (op, mode == VOIDmode ? mode : Pmode)")
4dd737
        (match_operand 0 "call_register_no_elim_operand")
4dd737
-       (and (not (match_test "TARGET_X32"))
4dd737
-	    (match_operand 0 "memory_operand"))))
4dd737
+       (and (not (match_test "ix86_indirect_branch_register"))
4dd737
+	    (and (not (match_test "TARGET_X32"))
4dd737
+		 (match_operand 0 "memory_operand")))))
4dd737
 
4dd737
 ;; Similarly, but for tail calls, in which we cannot allow memory references.
4dd737
 (define_special_predicate "sibcall_insn_operand"
4dd737
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
4dd737
index 5acd23a..4a365c7 100644
4dd737
--- a/gcc/doc/invoke.texi
4dd737
+++ b/gcc/doc/invoke.texi
4dd737
@@ -658,7 +658,8 @@ Objective-C and Objective-C++ Dialects}.
4dd737
 -m32 -m64 -mx32 -mlarge-data-threshold=@var{num} @gol
4dd737
 -msse2avx -mfentry -m8bit-idiv @gol
4dd737
 -mavx256-split-unaligned-load -mavx256-split-unaligned-store @gol
4dd737
--mindirect-branch=@var{choice} -mfunction-return==@var{choice}}
4dd737
+-mindirect-branch=@var{choice} -mfunction-return==@var{choice}
4dd737
+-mindirect-branch-register}
4dd737
 
4dd737
 @emph{i386 and x86-64 Windows Options}
4dd737
 @gccoptlist{-mconsole -mcygwin -mno-cygwin -mdll @gol
4dd737
@@ -14669,6 +14670,10 @@ object file.  You can control this behavior for a specific function by
4dd737
 using the function attribute @code{function_return}.
4dd737
 @xref{Function Attributes}.
4dd737
 
4dd737
+@item -mindirect-branch-register
4dd737
+@opindex -mindirect-branch-register
4dd737
+Force indirect call and jump via register.
4dd737
+
4dd737
 @end table
4dd737
 
4dd737
 These @samp{-m} switches are supported in addition to the above
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c
4dd737
index 034b4cc..321db77 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-1.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c
4dd737
index e0c57cb..d584516 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-2.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c
4dd737
index 3c0d4c3..9e24a38 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-3.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c
4dd737
index 14d4ef6..127b5d9 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-4.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
4dd737
index bc6b47a..17c2d0f 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 void func0 (void);
4dd737
 void func1 (void);
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c
4dd737
index 7c45142..cd7e8d7 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-1.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c
4dd737
index 9eebc84..4dbd7a5 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-2.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c
4dd737
index f938db0..4aeec18 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-3.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c
4dd737
index 4e58599..ac0e599 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-4.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c
4dd737
index b8d5024..573cf1e 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-5.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c
4dd737
index 455adab..b2b37fc 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-6.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c
4dd737
index 4595b84..4a43e19 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-attr-7.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -fno-pic" } */
4dd737
 
4dd737
 void func0 (void);
4dd737
 void func1 (void);
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c
4dd737
index f424181..72de88e 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-1.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c
4dd737
index ac54868..d4137b3 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-2.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c
4dd737
index 06ebf1c..d9964c2 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-3.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c
4dd737
index 1c8f944..d4dca4d 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-4.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
4dd737
index 86e9fd1..aece938 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-extern-7.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
 
4dd737
 void func0 (void);
4dd737
 void func1 (void);
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c
4dd737
index 4117a35..e3cea3f 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-1.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c
4dd737
index 650d55c..6222996 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-2.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c
4dd737
index 9540996..2eef6f3 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-3.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c
4dd737
index f3db6e2..e825a10 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-4.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
 
4dd737
 typedef void (*dispatch_t)(long offset);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
4dd737
index 764a375..c67066c 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
 
4dd737
 void func0 (void);
4dd737
 void func1 (void);
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
4dd737
new file mode 100644
4dd737
index 0000000..7d396a3
4dd737
--- /dev/null
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-1.c
4dd737
@@ -0,0 +1,22 @@
4dd737
+/* { dg-do compile } */
4dd737
+/* { dg-options "-O2 -mindirect-branch=thunk -mindirect-branch-register -fno-pic" } */
4dd737
+
4dd737
+typedef void (*dispatch_t)(long offset);
4dd737
+
4dd737
+dispatch_t dispatch;
4dd737
+
4dd737
+void
4dd737
+male_indirect_jump (long offset)
4dd737
+{
4dd737
+  dispatch(offset);
4dd737
+}
4dd737
+
4dd737
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
4dd737
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
4dd737
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
4dd737
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
4dd737
+/* { dg-final { scan-assembler {\tpause} } } */
4dd737
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch"  } } */
4dd737
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
4dd737
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk\n" } } */
4dd737
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk_bnd\n" } } */
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
4dd737
new file mode 100644
4dd737
index 0000000..e7e616b
4dd737
--- /dev/null
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-2.c
4dd737
@@ -0,0 +1,20 @@
4dd737
+/* { dg-do compile } */
4dd737
+/* { dg-options "-O2 -mindirect-branch=thunk-inline -mindirect-branch-register -fno-pic" } */
4dd737
+
4dd737
+typedef void (*dispatch_t)(long offset);
4dd737
+
4dd737
+dispatch_t dispatch;
4dd737
+
4dd737
+void
4dd737
+male_indirect_jump (long offset)
4dd737
+{
4dd737
+  dispatch(offset);
4dd737
+}
4dd737
+
4dd737
+/* { dg-final { scan-assembler "jmp\[ \t\]*\.LIND" } } */
4dd737
+/* { dg-final { scan-assembler "call\[ \t\]*\.LIND" } } */
4dd737
+/* { dg-final { scan-assembler "mov\[ \t\](%eax|%rax), \\((%esp|%rsp)\\)" } } */
4dd737
+/* { dg-final { scan-assembler {\tpause} } } */
4dd737
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch"  } } */
4dd737
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
4dd737
+/* { dg-final { scan-assembler-not "__x86_indirect_thunk" } } */
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
4dd737
new file mode 100644
4dd737
index 0000000..5320e92
4dd737
--- /dev/null
4dd737
+++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-register-3.c
4dd737
@@ -0,0 +1,19 @@
4dd737
+/* { dg-do compile } */
4dd737
+/* { dg-options "-O2 -mindirect-branch=thunk-extern -mindirect-branch-register -fno-pic" } */
4dd737
+
4dd737
+typedef void (*dispatch_t)(long offset);
4dd737
+
4dd737
+dispatch_t dispatch;
4dd737
+
4dd737
+void
4dd737
+male_indirect_jump (long offset)
4dd737
+{
4dd737
+  dispatch(offset);
4dd737
+}
4dd737
+
4dd737
+/* { dg-final { scan-assembler "jmp\[ \t\]*__x86_indirect_thunk_(r|e)ax" } } */
4dd737
+/* { dg-final { scan-assembler-not "push(?:l|q)\[ \t\]*_?dispatch"  } } */
4dd737
+/* { dg-final { scan-assembler-not "pushq\[ \t\]%rax" } } */
4dd737
+/* { dg-final { scan-assembler-not {\t(pause|pause|nop)} } } */
4dd737
+/* { dg-final { scan-assembler-not "jmp\[ \t\]*\.LIND" } } */
4dd737
+/* { dg-final { scan-assembler-not "call\[ \t\]*\.LIND" } } */
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
4dd737
index 3a6727b..e6fea84 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-10.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-inline -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
4dd737
index b8f6818..e239ec4 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-11.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk-extern -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
4dd737
index 01b0a02..fa31813 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-12.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
4dd737
index 4b497b5..fd5b41f 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-13.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737
 extern int foo (void) __attribute__ ((function_return("thunk")));
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
4dd737
index 4ae4c44..d606373 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-14.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-extern -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
4dd737
index 5b5bc76..75e45e2 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-15.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=keep -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737
 
4dd737
diff --git a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
4dd737
index fa24a1f..d1db41c 100644
4dd737
--- a/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
4dd737
+++ b/gcc/testsuite/gcc.target/i386/ret-thunk-9.c
4dd737
@@ -1,5 +1,5 @@
4dd737
 /* { dg-do compile } */
4dd737
-/* { dg-options "-O2 -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
4dd737
+/* { dg-options "-O2 -mno-indirect-branch-register -mno-indirect-branch-register -mfunction-return=thunk -mindirect-branch=thunk -fno-pic" } */
4dd737
 
4dd737
 extern void (*bar) (void);
4dd737