From 2ecf9ac7060bc6b902f5bed252e4a39f59d6f30b Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 13 Oct 2017 10:04:59 +0000 Subject: [PATCH] i386: Check red zone size in push peephole2 Check red zone size, instead of if red zone is available, in push peephole2s. gcc/ PR target/82499 * config/i386/i386.h (ix86_red_zone_size): New. * config/i386/i386.md (push peephole2s): Replace "!ix86_using_red_zone ()" with "ix86_red_zone_size == 0". gcc/testsuite/ PR target/82499 * gcc.target/i386/pr82499-1.c: New file. * gcc.target/i386/pr82499-2.c: Likewise. * gcc.target/i386/pr82499-3.c: Likewise. From-SVN: r253718 --- gcc/ChangeLog | 7 +++++++ gcc/config/i386/i386.h | 1 + gcc/config/i386/i386.md | 8 ++++---- gcc/testsuite/ChangeLog | 7 +++++++ gcc/testsuite/gcc.target/i386/pr82499-1.c | 21 +++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr82499-2.c | 21 +++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr82499-3.c | 21 +++++++++++++++++++++ 7 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr82499-1.c create mode 100644 gcc/testsuite/gcc.target/i386/pr82499-2.c create mode 100644 gcc/testsuite/gcc.target/i386/pr82499-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3b897e2dde7..57686022742 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-10-13 H.J. Lu + + PR target/82499 + * config/i386/i386.h (ix86_red_zone_size): New. + * config/i386/i386.md (push peephole2s): Replace + "!ix86_using_red_zone ()" with "ix86_red_zone_size == 0". + 2017-10-13 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index ef88d89cae2..b2feded0464 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -2603,6 +2603,7 @@ struct GTY(()) machine_function { #define ix86_current_function_calls_tls_descriptor \ (ix86_tls_descriptor_calls_expanded_in_cfun && df_regs_ever_live_p (SP_REG)) #define ix86_static_chain_on_stack (cfun->machine->static_chain_on_stack) +#define ix86_red_zone_size (cfun->machine->frame.red_zone_size) /* Control behavior of x86_file_start. */ #define X86_FILE_START_VERSION_DIRECTIVE false diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 3413b90028f..8262cf1c3f0 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -18814,7 +18814,7 @@ (clobber (mem:BLK (scratch)))])] "(TARGET_SINGLE_PUSH || optimize_insn_for_size_p ()) && INTVAL (operands[0]) == -GET_MODE_SIZE (word_mode) - && !ix86_using_red_zone ()" + && ix86_red_zone_size == 0" [(clobber (match_dup 1)) (parallel [(set (mem:W (pre_dec:P (reg:P SP_REG))) (match_dup 1)) (clobber (mem:BLK (scratch)))])]) @@ -18828,7 +18828,7 @@ (clobber (mem:BLK (scratch)))])] "(TARGET_DOUBLE_PUSH || optimize_insn_for_size_p ()) && INTVAL (operands[0]) == -2*GET_MODE_SIZE (word_mode) - && !ix86_using_red_zone ()" + && ix86_red_zone_size == 0" [(clobber (match_dup 1)) (set (mem:W (pre_dec:P (reg:P SP_REG))) (match_dup 1)) (parallel [(set (mem:W (pre_dec:P (reg:P SP_REG))) (match_dup 1)) @@ -18843,7 +18843,7 @@ (clobber (reg:CC FLAGS_REG))])] "(TARGET_SINGLE_PUSH || optimize_insn_for_size_p ()) && INTVAL (operands[0]) == -GET_MODE_SIZE (word_mode) - && !ix86_using_red_zone ()" + && ix86_red_zone_size == 0" [(clobber (match_dup 1)) (set (mem:W (pre_dec:P (reg:P SP_REG))) (match_dup 1))]) @@ -18855,7 +18855,7 @@ (clobber (reg:CC FLAGS_REG))])] "(TARGET_DOUBLE_PUSH || optimize_insn_for_size_p ()) && INTVAL (operands[0]) == -2*GET_MODE_SIZE (word_mode) - && !ix86_using_red_zone ()" + && ix86_red_zone_size == 0" [(clobber (match_dup 1)) (set (mem:W (pre_dec:P (reg:P SP_REG))) (match_dup 1)) (set (mem:W (pre_dec:P (reg:P SP_REG))) (match_dup 1))]) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 566864c2183..30ab9bd49e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-10-13 H.J. Lu + + PR target/82499 + * gcc.target/i386/pr82499-1.c: New file. + * gcc.target/i386/pr82499-2.c: Likewise. + * gcc.target/i386/pr82499-3.c: Likewise. + 2017-10-13 Jakub Jelinek PR target/82524 diff --git a/gcc/testsuite/gcc.target/i386/pr82499-1.c b/gcc/testsuite/gcc.target/i386/pr82499-1.c new file mode 100644 index 00000000000..3aba62a466f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr82499-1.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* The pic register save adds unavoidable stack pointer references. */ +/* { dg-skip-if "" { ia32 && { ! nonpic } } } */ +/* These options are selected to ensure 1 word needs to be allocated + on the stack to maintain alignment for the call. This should be + transformed to push+pop. We also want to force unwind info updates. */ +/* { dg-options "-Os -fomit-frame-pointer -fasynchronous-unwind-tables" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=3" { target ia32 } } */ +/* { dg-additional-options "-mpreferred-stack-boundary=4" { target { ! ia32 } } } */ +/* ms_abi has reserved stack-region. */ +/* { dg-skip-if "" { x86_64-*-mingw* } } */ + +extern void g (void); +int +f (void) +{ + g (); + return 42; +} + +/* { dg-final { scan-assembler-not "(sub|add)(l|q)\[\\t \]*\\$\[0-9\]*,\[\\t \]*%\[re\]?sp" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr82499-2.c b/gcc/testsuite/gcc.target/i386/pr82499-2.c new file mode 100644 index 00000000000..dde4d657e1a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr82499-2.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* The pic register save adds unavoidable stack pointer references. */ +/* { dg-skip-if "" { ia32 && { ! nonpic } } } */ +/* These options are selected to ensure 1 word needs to be allocated + on the stack to maintain alignment for the call. This should be + transformed to push+pop. We also want to force unwind info updates. */ +/* { dg-options "-Os -fomit-frame-pointer -fasynchronous-unwind-tables" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=3" { target ia32 } } */ +/* { dg-additional-options "-mpreferred-stack-boundary=4 -mno-red-zone" { target { ! ia32 } } } */ +/* ms_abi has reserved stack-region. */ +/* { dg-skip-if "" { x86_64-*-mingw* } } */ + +extern void g (void); +int +f (void) +{ + g (); + return 42; +} + +/* { dg-final { scan-assembler-not "(sub|add)(l|q)\[\\t \]*\\$\[0-9\]*,\[\\t \]*%\[re\]?sp" } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr82499-3.c b/gcc/testsuite/gcc.target/i386/pr82499-3.c new file mode 100644 index 00000000000..b55a860fcca --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr82499-3.c @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* The pic register save adds unavoidable stack pointer references. */ +/* { dg-skip-if "" { ia32 && { ! nonpic } } } */ +/* These options are selected to ensure 1 word needs to be allocated + on the stack to maintain alignment for the call. This should be + transformed to push+pop. We also want to force unwind info updates. */ +/* { dg-options "-O2 -mtune-ctrl=single_push,single_pop -fomit-frame-pointer -fasynchronous-unwind-tables" } */ +/* { dg-additional-options "-mpreferred-stack-boundary=3" { target ia32 } } */ +/* { dg-additional-options "-mpreferred-stack-boundary=4" { target { ! ia32 } } } */ +/* ms_abi has reserved stack-region. */ +/* { dg-skip-if "" { x86_64-*-mingw* } } */ + +extern void g (void); +int +f (void) +{ + g (); + return 42; +} + +/* { dg-final { scan-assembler-not "(sub|add)(l|q)\[\\t \]*\\$\[0-9\]*,\[\\t \]*%\[re\]?sp" } } */ -- 2.30.2