diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-01-03 12:22:17 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2014-01-03 12:22:17 +0000 |
commit | 0ff576b901c1d35d382abef6472c003809bbe585 (patch) | |
tree | 89abdbf02f19fba4de444c6faa612bc26c475a90 | |
parent | 4a7973e17f0725fa61793b53ea888d3e8d2a1cfa (diff) | |
download | gcc-0ff576b901c1d35d382abef6472c003809bbe585.tar.gz |
PR target/59625
* config/i386/i386.c (ix86_avoid_jump_mispredicts): Don't consider
asm goto as jump.
* gcc.target/i386/pr59625.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@206314 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/pr59625.c | 36 |
4 files changed, 55 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e4d71d700e9..09639d3cd56 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2014-01-03 Jakub Jelinek <jakub@redhat.com> + PR target/59625 + * config/i386/i386.c (ix86_avoid_jump_mispredicts): Don't consider + asm goto as jump. + * config/i386/i386.md (MODE_SIZE): New mode attribute. (push splitter): Use <P:MODE_SIZE> instead of GET_MODE_SIZE (<P:MODE>mode). diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 637ea655d50..d2f5b6e9fda 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -38825,7 +38825,10 @@ ix86_avoid_jump_mispredicts (void) The smallest offset in the page INSN can start is the case where START ends on the offset 0. Offset of INSN is then NBYTES - sizeof (INSN). We add p2align to 16byte window with maxskip 15 - NBYTES + sizeof (INSN). - */ + + Don't consider asm goto as jump, while it can contain a jump, it doesn't + have to, control transfer to label(s) can be performed through other + means, and also we estimate minimum length of all asm stmts as 0. */ for (insn = start; insn; insn = NEXT_INSN (insn)) { int min_size; @@ -38852,7 +38855,8 @@ ix86_avoid_jump_mispredicts (void) while (nbytes + max_skip >= 16) { start = NEXT_INSN (start); - if (JUMP_P (start) || CALL_P (start)) + if ((JUMP_P (start) && asm_noperands (PATTERN (start)) < 0) + || CALL_P (start)) njumps--, isjump = 1; else isjump = 0; @@ -38867,7 +38871,8 @@ ix86_avoid_jump_mispredicts (void) if (dump_file) fprintf (dump_file, "Insn %i estimated to %i bytes\n", INSN_UID (insn), min_size); - if (JUMP_P (insn) || CALL_P (insn)) + if ((JUMP_P (insn) && asm_noperands (PATTERN (insn)) < 0) + || CALL_P (insn)) njumps++; else continue; @@ -38875,7 +38880,8 @@ ix86_avoid_jump_mispredicts (void) while (njumps > 3) { start = NEXT_INSN (start); - if (JUMP_P (start) || CALL_P (start)) + if ((JUMP_P (start) && asm_noperands (PATTERN (start)) < 0) + || CALL_P (start)) njumps--, isjump = 1; else isjump = 0; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0950914255e..49b55f8b49e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-01-03 Jakub Jelinek <jakub@redhat.com> + + PR target/59625 + * gcc.target/i386/pr59625.c: New test. + 2014-01-03 Paolo Carlini <paolo.carlini@oracle.com> Core DR 1442 diff --git a/gcc/testsuite/gcc.target/i386/pr59625.c b/gcc/testsuite/gcc.target/i386/pr59625.c new file mode 100644 index 00000000000..8e1a7794bc4 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr59625.c @@ -0,0 +1,36 @@ +/* PR target/59625 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mtune=atom" } */ + +int +foo (void) +{ + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + asm goto ("" : : : : lab); + return 0; +lab: + return 1; +} + +/* Verify we don't consider asm goto as a jump for four jumps limit + optimization. asm goto doesn't have to contain a jump at all, + the branching to labels can happen through different means. */ +/* { dg-final { scan-assembler-not "(p2align\[^\n\r\]*\[\n\r]*\[^\n\r\]*){8}p2align" } } */ |