* [PATCH 1/2] arc: Use @pcl assembler syntax instead of invalid expressions
2017-04-12 15:24 [PATCH 0/2] ARC Zero Overhead Loop Fixes Andrew Burgess
2017-04-12 15:24 ` [PATCH 2/2] arc: Fix for loop end detection Andrew Burgess
@ 2017-04-12 15:24 ` Andrew Burgess
2017-04-14 11:30 ` [PATCH 0/2] ARC Zero Overhead Loop Fixes Claudiu Zissulescu
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Burgess @ 2017-04-12 15:24 UTC (permalink / raw)
To: gcc-patches; +Cc: guybe, Claudiu.Zissulescu, Andrew Burgess
The old ARC assembler would accept expressions like 'LABEL-(.&-4)'
which would calculate the offset from the PCL to LABEL. The new ARC
assembler does not accept these expressions, instead there's an @pcl
synax, used like LABEL@pcl which gives the offset from PCL to LABEL.
Most of the use of the old expression syntax have been removed,
however, this one got missed.
gcc/ChangeLog:
* config/arc/arc.md (doloop_begin_i): Use @pcl assembler syntax.
---
gcc/ChangeLog | 4 ++++
gcc/config/arc/arc.md | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md
index 88b7fca..f707bd0 100644
--- a/gcc/config/arc/arc.md
+++ b/gcc/config/arc/arc.md
@@ -5070,7 +5070,7 @@
{
/* ??? Can do better for when a scratch register
is known. But that would require extra testing. */
- return "push_s r0\;add r0,pcl,%4-(.&-4)\;sr r0,[2]; LP_START\;add r0,pcl,.L__GCC__LP%1-(.&-4)\;sr r0,[3]; LP_END\;pop_s r0";
+ return "push_s r0\;add r0,pcl,%4@pcl\;sr r0,[2]; LP_START\;add r0,pcl,.L__GCC__LP%1@pcl\;sr r0,[3]; LP_END\;pop_s r0";
}
/* Check if the loop end is in range to be set by the lp instruction. */
size = INTVAL (operands[3]) < 2 ? 0 : 2048;
--
2.4.11
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] arc: Fix for loop end detection
2017-04-12 15:24 [PATCH 0/2] ARC Zero Overhead Loop Fixes Andrew Burgess
@ 2017-04-12 15:24 ` Andrew Burgess
2017-04-12 15:24 ` [PATCH 1/2] arc: Use @pcl assembler syntax instead of invalid expressions Andrew Burgess
2017-04-14 11:30 ` [PATCH 0/2] ARC Zero Overhead Loop Fixes Claudiu Zissulescu
2 siblings, 0 replies; 5+ messages in thread
From: Andrew Burgess @ 2017-04-12 15:24 UTC (permalink / raw)
To: gcc-patches; +Cc: guybe, Claudiu.Zissulescu, Andrew Burgess
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.
---
gcc/ChangeLog | 6 +++++
gcc/config/arc/arc.c | 5 ++--
gcc/testsuite/ChangeLog | 4 ++++
gcc/testsuite/gcc.target/arc/loop-1.c | 45 +++++++++++++++++++++++++++++++++++
4 files changed, 58 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/arc/loop-1.c
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
index 0563a74..39b198d 100644
--- a/gcc/config/arc/arc.c
+++ b/gcc/config/arc/arc.c
@@ -6573,8 +6573,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;
@@ -6585,6 +6583,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/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__" } } */
--
2.4.11
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 0/2] ARC Zero Overhead Loop Fixes
@ 2017-04-12 15:24 Andrew Burgess
2017-04-12 15:24 ` [PATCH 2/2] arc: Fix for loop end detection Andrew Burgess
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Andrew Burgess @ 2017-04-12 15:24 UTC (permalink / raw)
To: gcc-patches; +Cc: guybe, Claudiu.Zissulescu, Andrew Burgess
Found two issues with the ARC loop detection. The first generates
code that the current assembler can't handle, while the second causes
some loops to be missed.
--
Andrew Burgess (2):
arc: Use @pcl assembler syntax instead of invalid expressions
arc: Fix for loop end detection
gcc/ChangeLog | 10 ++++++++
gcc/config/arc/arc.c | 5 ++--
gcc/config/arc/arc.md | 2 +-
gcc/testsuite/ChangeLog | 4 ++++
gcc/testsuite/gcc.target/arc/loop-1.c | 45 +++++++++++++++++++++++++++++++++++
5 files changed, 63 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/arc/loop-1.c
--
2.4.11
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH 0/2] ARC Zero Overhead Loop Fixes
2017-04-12 15:24 [PATCH 0/2] ARC Zero Overhead Loop Fixes Andrew Burgess
2017-04-12 15:24 ` [PATCH 2/2] arc: Fix for loop end detection Andrew Burgess
2017-04-12 15:24 ` [PATCH 1/2] arc: Use @pcl assembler syntax instead of invalid expressions Andrew Burgess
@ 2017-04-14 11:30 ` Claudiu Zissulescu
2017-04-14 21:22 ` Andrew Burgess
2 siblings, 1 reply; 5+ messages in thread
From: Claudiu Zissulescu @ 2017-04-14 11:30 UTC (permalink / raw)
To: Andrew Burgess, gcc-patches; +Cc: guybe
Hi,
> Andrew Burgess (2):
> arc: Use @pcl assembler syntax instead of invalid expressions
> arc: Fix for loop end detection
>
Both patches looks good to me.
Claudiu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] ARC Zero Overhead Loop Fixes
2017-04-14 11:30 ` [PATCH 0/2] ARC Zero Overhead Loop Fixes Claudiu Zissulescu
@ 2017-04-14 21:22 ` Andrew Burgess
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Burgess @ 2017-04-14 21:22 UTC (permalink / raw)
To: gcc-patches; +Cc: Claudiu Zissulescu, Guy Benyei
* Claudiu Zissulescu <Claudiu.Zissulescu@synopsys.com> [2017-04-14 11:20:43 +0000]:
> Hi,
>
> > Andrew Burgess (2):
> > arc: Use @pcl assembler syntax instead of invalid expressions
> > arc: Fix for loop end detection
> >
>
> Both patches looks good to me.
Thanks committed as r246932 and r246933.
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-14 21:17 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 15:24 [PATCH 0/2] ARC Zero Overhead Loop Fixes Andrew Burgess
2017-04-12 15:24 ` [PATCH 2/2] arc: Fix for loop end detection Andrew Burgess
2017-04-12 15:24 ` [PATCH 1/2] arc: Use @pcl assembler syntax instead of invalid expressions Andrew Burgess
2017-04-14 11:30 ` [PATCH 0/2] ARC Zero Overhead Loop Fixes Claudiu Zissulescu
2017-04-14 21:22 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).