diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2017-04-14 22:14:34 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@gcc.gnu.org> | 2017-04-14 22:14:34 +0100 |
commit | dd3d6a42fcd881b1f4f8fbd6cc82c1f14124b317 (patch) | |
tree | d956a464bc5962f2dee2f1d70f39ffd824ed2d80 /gcc | |
parent | 8c1d6b64e3e163e434b2f8d8521a31c9469089f0 (diff) | |
download | gcc-dd3d6a42fcd881b1f4f8fbd6cc82c1f14124b317.zip gcc-dd3d6a42fcd881b1f4f8fbd6cc82c1f14124b317.tar.gz gcc-dd3d6a42fcd881b1f4f8fbd6cc82c1f14124b317.tar.bz2 |
arc: Fix for loop end detection
We use a negative ID number to link together the doloop_begin and
doloop_end instructions. This negative ID number is setup within
doloop_begin, at this point the ID is stored into the loop end
instruction (doloop_end_i) and placed into the doloop_begin_i
instruction.
In arc.c (arc_reorg) we extract the ID from the doloop_end_i
instruction in order to find the matching doloop_begin_i instruction,
though the ID is only used in some cases.
Currently in arc_reorg when we extract the ID we negate it. This
negation is invalid. The ID stored in both doloop_end_i and
doloop_begin_i is already negative, the negation in arc_reorg means
that if we need to use the ID to find the doloop_begin_i then we will
never find it (as the IDs will never match).
This commit removes the unneeded negation, moves the extraction of the
ID into a more appropriately scoped block and adds a new test for this
issue.
gcc/ChangeLog:
* config/arc/arc.c (arc_reorg): Move loop_end_id into a more local
block, and do not negate it, the stored id is already negative.
gcc/testsuite/ChangeLog:
* gcc.target/arc/loop-1.c: New file.
Co-Authored-By: Guy Benyei <guybe@mellanox.com>
From-SVN: r246933
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/config/arc/arc.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/arc/loop-1.c | 45 |
4 files changed, 58 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8c4728c..2807eb2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,4 +1,10 @@ 2017-04-14 Andrew Burgess <andrew.burgess@embecosm.com> + Guy Benyei <guybe@mellanox.com> + + * config/arc/arc.c (arc_reorg): Move loop_end_id into a more local + block, and do not negate it, the stored id is already negative. + +2017-04-14 Andrew Burgess <andrew.burgess@embecosm.com> * config/arc/arc.md (doloop_begin_i): Use @pcl assembler syntax. diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index c8ffa1a..92fecad 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -6569,8 +6569,6 @@ arc_reorg (void) rtx_insn *lp_simple = NULL; rtx_insn *next = NULL; rtx op0 = XEXP (XVECEXP (PATTERN (insn), 0, 1), 0); - HOST_WIDE_INT loop_end_id - = -INTVAL (XEXP (XVECEXP (PATTERN (insn), 0, 4), 0)); int seen_label = 0; for (lp = prev; @@ -6581,6 +6579,9 @@ arc_reorg (void) if (!lp || !NONJUMP_INSN_P (lp) || dead_or_set_regno_p (lp, LP_COUNT)) { + HOST_WIDE_INT loop_end_id + = INTVAL (XEXP (XVECEXP (PATTERN (insn), 0, 4), 0)); + for (prev = next = insn, lp = NULL ; prev || next;) { if (prev) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a1d74b6..3de763f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2017-04-14 Andrew Burgess <andrew.burgess@embecosm.com> + + * gcc.target/arc/loop-1.c: New file. + 2017-04-14 Michael Meissner <meissner@linux.vnet.ibm.com> PR target/80098 diff --git a/gcc/testsuite/gcc.target/arc/loop-1.c b/gcc/testsuite/gcc.target/arc/loop-1.c new file mode 100644 index 0000000..1afe8eb --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* This case would fail to make use of the zero-overhead loop + instruction at one time due to a bug. */ + +extern char a[]; + +struct some_t +{ + struct + { + int aaa; + short bbb; + char ccc; + char ddd; + } ppp[8]; + + int www[1]; +}; + +int b; + +void +some_function () +{ + struct some_t *tmp = (struct some_t *) a; + + while ((*tmp).ppp[b].ccc) + while(0); + + for (; b; b++) + { + if (tmp->ppp[b].ccc) + { + int c = tmp->ppp[b].bbb; + int d = tmp->ppp[b].aaa; + int e = d - tmp->www[c]; + if (e) + tmp->ppp[b].ddd = 1; + } + } +} + +/* { dg-final { scan-assembler "\[^\n\]+lp \\.L__GCC__" } } */ |