x86: Disable jump tables when retpolines are used (PR target/86952).
authorMartin Liska <mliska@suse.cz>
Fri, 8 Mar 2019 12:55:40 +0000 (13:55 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Fri, 8 Mar 2019 12:55:40 +0000 (12:55 +0000)
2019-03-08  Martin Liska  <mliska@suse.cz>

PR target/86952
* config/i386/i386.c (ix86_option_override_internal): Disable
jump tables when retpolines are used.
2019-03-08  Martin Liska  <mliska@suse.cz>

PR target/86952
* gcc.target/i386/pr86952.c: New test.
* gcc.target/i386/indirect-thunk-7.c: Use jump tables to match
scanned pattern.
* gcc.target/i386/indirect-thunk-inline-7.c: Likewise.

From-SVN: r269492

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/indirect-thunk-7.c
gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c
gcc/testsuite/gcc.target/i386/pr86952.c [new file with mode: 0644]

index de7bdde2b9ae77225d917012159040a4604f1989..5e737bd1842d49057007a4e2176f92ab9665e0ac 100644 (file)
@@ -1,3 +1,9 @@
+2019-03-08  Martin Liska  <mliska@suse.cz>
+
+       PR target/86952
+       * config/i386/i386.c (ix86_option_override_internal): Disable
+       jump tables when retpolines are used.
+
 2019-03-08  Jan Hubicka  <hubicka@ucw.cz>
 
        PR go/63560
index 2d6a993238b56352badf7f58b985509817a1adb8..319caeda7b50ba0d1c996f3b9b2ee29df1ea1adb 100644 (file)
@@ -4894,6 +4894,12 @@ ix86_option_override_internal (bool main_args_p,
                           opts->x_param_values,
                           opts_set->x_param_values);
 
+  /* PR86952: jump table usage with retpolines is slow.
+     The PR provides some numbers about the slowness.  */
+  if (ix86_indirect_branch != indirect_branch_keep
+      && !opts_set->x_flag_jump_tables)
+    opts->x_flag_jump_tables = 0;
+
   return true;
 }
 
index 4010924cd5adcebf8935a2de32cc2b88ffd0f77d..9d386f607e279da68a34111672cd1e7977c09345 100644 (file)
@@ -1,3 +1,11 @@
+2019-03-08  Martin Liska  <mliska@suse.cz>
+
+       PR target/86952
+       * gcc.target/i386/pr86952.c: New test.
+       * gcc.target/i386/indirect-thunk-7.c: Use jump tables to match
+       scanned pattern.
+       * gcc.target/i386/indirect-thunk-inline-7.c: Likewise.
+
 2019-03-08  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/89585
index 3c72036dbaf43a4309d73eda3e03b8ce40cfc69d..53868f46558d8d760bcec686c20a659a10248027 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic" } */
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk -fno-pic -fjump-tables" } */
 
 void func0 (void);
 void func1 (void);
index ea009245a58f79a7e565d27b4c4275355732dc4b..e6f064959a1cef2d9cb0a4ba97f0b2422d1f074f 100644 (file)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic" } */
+/* { dg-options "-O2 -mno-indirect-branch-register -mfunction-return=keep -mindirect-branch=thunk-inline -fno-pic -fjump-tables" } */
 
 void func0 (void);
 void func1 (void);
diff --git a/gcc/testsuite/gcc.target/i386/pr86952.c b/gcc/testsuite/gcc.target/i386/pr86952.c
new file mode 100644 (file)
index 0000000..3ff3e35
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mindirect-branch=thunk -fdump-tree-switchlower1" } */
+
+int global;
+
+int 
+foo (int x)
+{
+  switch (x & 7)
+    {
+      case 0: ; return 1722;
+      case 1: global += 1; return 1060;
+      case 2: ; return 1990;
+      case 3: ; return 1242;
+      case 4: ; return 1466;
+      case 5: ; return 894;
+      case 6: ; return 570;
+      case 7: ; return 572;
+      default: return 0;
+    }
+}
+
+/* { dg-final { scan-tree-dump ";; GIMPLE switch case clusters: 1 2 3 4 5 6 7" "switchlower1" } } */