From: Pat Haugen Date: Wed, 30 Aug 2017 18:36:12 +0000 (+0000) Subject: rs6000.c (rs6000_emit_prologue_move_from_cr): Rename from rs6000_emit_move_from_cr... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e0bd5a2824b13532b5377b52b90dfcd4cfce9c0d;p=gcc.git rs6000.c (rs6000_emit_prologue_move_from_cr): Rename from rs6000_emit_move_from_cr and call renamed function. * config/rs6000/rs6000.c (rs6000_emit_prologue_move_from_cr): Rename from rs6000_emit_move_from_cr and call renamed function. (rs6000_emit_prologue): Call renamed functions. * config/rs6000/rs6000.md (prologue_movesi_from_cr): Rename from movesi_from_cr, remove volatile CRs. * gcc.target/powerpc/cr_shrink-wrap.c: New. From-SVN: r251543 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index cc0dc48575e..37d888fa039 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-08-30 Pat Haugen + + * config/rs6000/rs6000.c (rs6000_emit_prologue_move_from_cr): Rename from + rs6000_emit_move_from_cr and call renamed function. + (rs6000_emit_prologue): Call renamed functions. + * config/rs6000/rs6000.md (prologue_movesi_from_cr): Rename from + movesi_from_cr, remove volatile CRs. + 2017-08-30 Jon Beniston Richard Biener diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index 9df7705a42a..cf744d8bf62 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -26097,10 +26097,14 @@ rs6000_emit_savres_rtx (rs6000_stack_t *info, return insn; } -/* Emit code to store CR fields that need to be saved into REG. */ +/* Emit prologue code to store CR fields that need to be saved into REG. This + function should only be called when moving the non-volatile CRs to REG, it + is not a general purpose routine to move the entire set of CRs to REG. + Specifically, gen_prologue_movesi_from_cr() does not contain uses of the + volatile CRs. */ static void -rs6000_emit_move_from_cr (rtx reg) +rs6000_emit_prologue_move_from_cr (rtx reg) { /* Only the ELFv2 ABI allows storing only selected fields. */ if (DEFAULT_ABI == ABI_ELFv2 && TARGET_MFCRF) @@ -26131,7 +26135,7 @@ rs6000_emit_move_from_cr (rtx reg) as well, using logical operations to combine the values. */ } - emit_insn (gen_movesi_from_cr (reg)); + emit_insn (gen_prologue_movesi_from_cr (reg)); } /* Return whether the split-stack arg pointer (r12) is used. */ @@ -26871,7 +26875,7 @@ rs6000_emit_prologue (void) { cr_save_rtx = gen_rtx_REG (SImode, cr_save_regno); START_USE (cr_save_regno); - rs6000_emit_move_from_cr (cr_save_rtx); + rs6000_emit_prologue_move_from_cr (cr_save_rtx); } /* Do any required saving of fpr's. If only one or two to save, do @@ -27109,7 +27113,7 @@ rs6000_emit_prologue (void) { START_USE (0); cr_save_rtx = gen_rtx_REG (SImode, 0); - rs6000_emit_move_from_cr (cr_save_rtx); + rs6000_emit_prologue_move_from_cr (cr_save_rtx); } /* Saving CR requires a two-instruction sequence: one instruction @@ -27196,7 +27200,7 @@ rs6000_emit_prologue (void) /* ??? We might get better performance by using multiple mfocrf instructions. */ crsave = gen_rtx_REG (SImode, 0); - emit_insn (gen_movesi_from_cr (crsave)); + emit_insn (gen_prologue_movesi_from_cr (crsave)); for (i = 0; i < 8; i++) if (!call_used_regs[CR0_REGNO + i]) diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md index c0c392ce596..f67e949a3a3 100644 --- a/gcc/config/rs6000/rs6000.md +++ b/gcc/config/rs6000/rs6000.md @@ -13032,12 +13032,14 @@ }" [(set_attr "type" "mfcrf")]) -(define_insn "movesi_from_cr" +;; Don't include the volatile CRs since their values are not used wrt CR save +;; in the prologue and doing so prevents shrink-wrapping because we can't move the +;; prologue past an insn (early exit test) that defines a register used in the +;; prologue. +(define_insn "prologue_movesi_from_cr" [(set (match_operand:SI 0 "gpc_reg_operand" "=r") - (unspec:SI [(reg:CC CR0_REGNO) (reg:CC CR1_REGNO) - (reg:CC CR2_REGNO) (reg:CC CR3_REGNO) - (reg:CC CR4_REGNO) (reg:CC CR5_REGNO) - (reg:CC CR6_REGNO) (reg:CC CR7_REGNO)] + (unspec:SI [(reg:CC CR2_REGNO) (reg:CC CR3_REGNO) + (reg:CC CR4_REGNO)] UNSPEC_MOVESI_FROM_CR))] "" "mfcr %0" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0a5d125bae7..331b6dd29f8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-08-30 Pat Haugen + + * gcc.target/powerpc/cr_shrink-wrap.c: New. + 2017-08-30 Michael Meissner PR target/82015 diff --git a/gcc/testsuite/gcc.target/powerpc/cr_shrink-wrap.c b/gcc/testsuite/gcc.target/powerpc/cr_shrink-wrap.c new file mode 100644 index 00000000000..d16b3fdf23b --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/cr_shrink-wrap.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-rtl-pro_and_epilogue" } */ + +void foo(int i) +{ + if (i > 0) + /* Non-volatile CR kill on true path should not prevent shrink-wrap. */ + asm ("" : : : "cr2", "cr3"); +} + +/* { dg-final { scan-rtl-dump-times "Performing shrink-wrapping" 1 "pro_and_epilogue" } } */