public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RISC-V: fix a typo in riscv.h
@ 2020-09-14  7:15 Yeting Kuo
  2020-09-14  7:19 ` Kito Cheng
  0 siblings, 1 reply; 4+ messages in thread
From: Yeting Kuo @ 2020-09-14  7:15 UTC (permalink / raw)
  To: gcc-patches

Hi all,

The patch fixes a typo that would make some errors in fast-unaligned-access
targets.

    RISC-V: fix a typo in riscv.h

    2020-09-14 Yeting Kuo <fakepaper56@gmail.com>

    gcc/
            * config/riscv/riscv.h

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 9f67d82e74e..b7b4a1c88a5 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -941,7 +941,7 @@ extern unsigned riscv_stack_boundary;

 /* This is the maximum value that can be represented in a compressed
load/store
    offset (an unsigned 5-bit value scaled by 4).  */
-#define CSW_MAX_OFFSET ((4LL << C_S_BITS) - 1) & ~3
+#define CSW_MAX_OFFSET (((4LL << C_S_BITS) - 1) & ~3)

 /* Called from RISCV_REORG, this is defined in riscv-sr.c.  */

Best Regard,
Yeting

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RISC-V: fix a typo in riscv.h
  2020-09-14  7:15 RISC-V: fix a typo in riscv.h Yeting Kuo
@ 2020-09-14  7:19 ` Kito Cheng
  2020-09-14 11:06   ` Yeting Kuo
  0 siblings, 1 reply; 4+ messages in thread
From: Kito Cheng @ 2020-09-14  7:19 UTC (permalink / raw)
  To: Yeting Kuo; +Cc: GCC Patches

Hi Yeting:

Could you provide a test case for that?

On Mon, Sep 14, 2020 at 3:15 PM Yeting Kuo via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi all,
>
> The patch fixes a typo that would make some errors in fast-unaligned-access
> targets.
>
>     RISC-V: fix a typo in riscv.h
>
>     2020-09-14 Yeting Kuo <fakepaper56@gmail.com>
>
>     gcc/
>             * config/riscv/riscv.h
>
> diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
> index 9f67d82e74e..b7b4a1c88a5 100644
> --- a/gcc/config/riscv/riscv.h
> +++ b/gcc/config/riscv/riscv.h
> @@ -941,7 +941,7 @@ extern unsigned riscv_stack_boundary;
>
>  /* This is the maximum value that can be represented in a compressed
> load/store
>     offset (an unsigned 5-bit value scaled by 4).  */
> -#define CSW_MAX_OFFSET ((4LL << C_S_BITS) - 1) & ~3
> +#define CSW_MAX_OFFSET (((4LL << C_S_BITS) - 1) & ~3)
>
>  /* Called from RISCV_REORG, this is defined in riscv-sr.c.  */
>
> Best Regard,
> Yeting

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RISC-V: fix a typo in riscv.h
  2020-09-14  7:19 ` Kito Cheng
@ 2020-09-14 11:06   ` Yeting Kuo
  2020-09-17 21:30     ` Jeff Law
  0 siblings, 1 reply; 4+ messages in thread
From: Yeting Kuo @ 2020-09-14 11:06 UTC (permalink / raw)
  To: Kito Cheng; +Cc: GCC Patches

Hi Kito,

> > Could you provide a test case for that?
>
I add the test case and update the git message.
    RISC-V: fix a typo in riscv.h

    The missing parentheses would make shorten-memrefs pass give a
    wrong base when the offset of load/store is not multiple of 4.

    2020-09-14 Yeting Kuo <fakepaper56@gmail.com>

    gcc/ChangeLog:
            * config/riscv/riscv.h

    gcc/testsuite/ChangeLog:
            * gcc.target/riscv/shorten-memrefs-8.c: New test.

diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 9f67d82e74e..b7b4a1c88a5 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -941,7 +941,7 @@ extern unsigned riscv_stack_boundary;

 /* This is the maximum value that can be represented in a compressed
load/store
    offset (an unsigned 5-bit value scaled by 4).  */
-#define CSW_MAX_OFFSET ((4LL << C_S_BITS) - 1) & ~3
+#define CSW_MAX_OFFSET (((4LL << C_S_BITS) - 1) & ~3)

 /* Called from RISCV_REORG, this is defined in riscv-sr.c.  */
diff --git a/gcc/testsuite/gcc.target/riscv/shorten-memrefs-8.c
b/gcc/testsuite/gcc.target/riscv/shorten-memrefs-8.c
new file mode 100644
index 00000000000..f7428bd86cb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/shorten-memrefs-8.c
@@ -0,0 +1,26 @@
+/* { dg-options "-Os -march=rv32imc -mabi=ilp32" } */
+
+/* shorten_memrefs should use a correct base address*/
+
+void
+store (char *p, int k)
+{
+  *(int *)(p + 17) = k;
+  *(int *)(p + 21) = k;
+  *(int *)(p + 25) = k;
+  *(int *)(p + 29) = k;
+}
+
+int
+load (char *p)
+{
+  int a = 0;
+  a += *(int *)(p + 17);
+  a += *(int *)(p + 21);
+  a += *(int *)(p + 25);
+  a += *(int *)(p + 29);
+  return a;
+}
+
+/* { dg-final { scan-assembler "store:\n\taddi\ta\[0-7\],a\[0-7\],1" } } */
+/* { dg-final { scan-assembler "load:\n\taddi\ta\[0-7\],a\[0-7\],1" } } */

Thanks,
Yeting

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RISC-V: fix a typo in riscv.h
  2020-09-14 11:06   ` Yeting Kuo
@ 2020-09-17 21:30     ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2020-09-17 21:30 UTC (permalink / raw)
  To: Yeting Kuo, Kito Cheng; +Cc: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]


On 9/14/20 5:06 AM, Yeting Kuo via Gcc-patches wrote:
> Hi Kito,
>
>>> Could you provide a test case for that?
> I add the test case and update the git message.
>     RISC-V: fix a typo in riscv.h
>
>     The missing parentheses would make shorten-memrefs pass give a
>     wrong base when the offset of load/store is not multiple of 4.
>
>     2020-09-14 Yeting Kuo <fakepaper56@gmail.com>
>
>     gcc/ChangeLog:
>             * config/riscv/riscv.h
>
>     gcc/testsuite/ChangeLog:
>             * gcc.target/riscv/shorten-memrefs-8.c: New test.

Thanks.  I made a minor fix in the ChangeLog entry and pushed this to
the trunk.


jeff



[-- Attachment #2: pEpkey.asc --]
[-- Type: application/pgp-keys, Size: 1763 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-17 21:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14  7:15 RISC-V: fix a typo in riscv.h Yeting Kuo
2020-09-14  7:19 ` Kito Cheng
2020-09-14 11:06   ` Yeting Kuo
2020-09-17 21:30     ` Jeff Law

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).