x86: Disable jump tables when retpolines are used (PR target/86952).

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
This commit is contained in:
Martin Liska 2019-03-08 13:55:40 +01:00 committed by Martin Liska
parent 37555926fe
commit f62d3527db
6 changed files with 45 additions and 2 deletions

View 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

View 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;
}

View 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

View 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);

View 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);

View File

@ -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" } } */