aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorSegher Boessenkool <segher@kernel.crashing.org>2017-05-22 23:20:51 +0200
committerSegher Boessenkool <segher@gcc.gnu.org>2017-05-22 23:20:51 +0200
commit2ea0d750147582b5d7bf405dce36f864618eacbd (patch)
tree34cc1dd5be60d131c6db256516f0ff7f4e71c648 /gcc
parent25b8168681bb5d1bc5e74c54b8f4cad635636ff1 (diff)
downloadgcc-2ea0d750147582b5d7bf405dce36f864618eacbd.zip
gcc-2ea0d750147582b5d7bf405dce36f864618eacbd.tar.gz
gcc-2ea0d750147582b5d7bf405dce36f864618eacbd.tar.bz2
cfgcleanup: Ignore clobbers in bb_is_just_return
The function bb_is_just_return finds if the BB it is asked about does just a return and nothing else. It currently does not allow clobbers in the block either, which we of course can allow just fine. This patch changes that. * cfgcleanup.c (bb_is_just_return): Allow CLOBBERs. gcc/testsuite/ From-SVN: r248351
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog4
-rw-r--r--gcc/cfgcleanup.c14
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.target/powerpc/conditional-return.c15
4 files changed, 31 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7bdd6f2..713654d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-22 Segher Boessenkool <segher@kernel.crashing.org>
+
+ * cfgcleanup.c (bb_is_just_return): Allow CLOBBERs.
+
2017-05-22 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80809
diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
index f68a964..3e1406c 100644
--- a/gcc/cfgcleanup.c
+++ b/gcc/cfgcleanup.c
@@ -2666,7 +2666,7 @@ trivially_empty_bb_p (basic_block bb)
/* Return true if BB contains just a return and possibly a USE of the
return value. Fill in *RET and *USE with the return and use insns
- if any found, otherwise NULL. */
+ if any found, otherwise NULL. All CLOBBERs are ignored. */
static bool
bb_is_just_return (basic_block bb, rtx_insn **ret, rtx_insn **use)
@@ -2680,13 +2680,15 @@ bb_is_just_return (basic_block bb, rtx_insn **ret, rtx_insn **use)
FOR_BB_INSNS (bb, insn)
if (NONDEBUG_INSN_P (insn))
{
- if (!*ret && ANY_RETURN_P (PATTERN (insn)))
+ rtx pat = PATTERN (insn);
+
+ if (!*ret && ANY_RETURN_P (pat))
*ret = insn;
- else if (!*ret && !*use && GET_CODE (PATTERN (insn)) == USE
- && REG_P (XEXP (PATTERN (insn), 0))
- && REG_FUNCTION_VALUE_P (XEXP (PATTERN (insn), 0)))
+ else if (!*ret && !*use && GET_CODE (pat) == USE
+ && REG_P (XEXP (pat, 0))
+ && REG_FUNCTION_VALUE_P (XEXP (pat, 0)))
*use = insn;
- else
+ else if (GET_CODE (pat) != CLOBBER)
return false;
}
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 08cfe12..c55b0ee 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-22 Segher Boessenkool <segher@kernel.crashing.org>
+
+ * gcc.target/powerpc/conditional-return.c: New testcase.
+
2017-05-22 Bill Schmidt <wschmidt@linux.vnet.ibm.com>
* gcc.target/powerpc/p8-vec-xl-xst.c: Fix target string to
diff --git a/gcc/testsuite/gcc.target/powerpc/conditional-return.c b/gcc/testsuite/gcc.target/powerpc/conditional-return.c
new file mode 100644
index 0000000..6b3ef5f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/conditional-return.c
@@ -0,0 +1,15 @@
+/* Check that a conditional return is used. */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+/* { dg-final { scan-assembler {\mbeqlr\M} } } */
+
+
+int f(int x)
+{
+ if (x)
+ return x + 31;
+
+ return;
+}