From: Martin Liska Date: Fri, 8 Mar 2019 12:55:40 +0000 (+0100) Subject: x86: Disable jump tables when retpolines are used (PR target/86952). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f62d3527db908646a518b1c1412210a3ae645d73;p=gcc.git x86: Disable jump tables when retpolines are used (PR target/86952). 2019-03-08 Martin Liska PR target/86952 * config/i386/i386.c (ix86_option_override_internal): Disable jump tables when retpolines are used. 2019-03-08 Martin Liska 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index de7bdde2b9a..5e737bd1842 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-08 Martin Liska + + PR target/86952 + * config/i386/i386.c (ix86_option_override_internal): Disable + jump tables when retpolines are used. + 2019-03-08 Jan Hubicka PR go/63560 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2d6a993238b..319caeda7b5 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4010924cd5a..9d386f607e2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2019-03-08 Martin Liska + + 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 PR c++/89585 diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c index 3c72036dbaf..53868f46558 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-7.c @@ -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); diff --git a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c index ea009245a58..e6f064959a1 100644 --- a/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c +++ b/gcc/testsuite/gcc.target/i386/indirect-thunk-inline-7.c @@ -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 index 00000000000..3ff3e354878 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr86952.c @@ -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" } } */