* [Patch, microblaze]: Correct the const high double immediate value
@ 2020-11-09 5:43 Nagaraju Mekala
2020-11-11 3:36 ` Michael Eager
0 siblings, 1 reply; 3+ messages in thread
From: Nagaraju Mekala @ 2020-11-09 5:43 UTC (permalink / raw)
To: Michael Eager, gcc-patches; +Cc: Sadanand Mutyala
[-- Attachment #1: Type: text/plain, Size: 3427 bytes --]
Hello All,
This patch will load the DI mode immediate values from
REAL_VALUE_FROM_CONST_DOUBLE and REAL_VALUE_TO_TARGET_DOUBLE functions, as
CONST_DOUBLE_HIGH was returning the sign extension value even for the
unsigned long long constants also
gcc/ChangeLog:
* config/microblaze/microblaze.c (print_operand): Update
loading of DI mode immediate values using
REAL_VALUE_FROM_CONST_DOUBLE and
REAL_VALUE_TO_TARGET_DOUBLE
gcc/testsuite/ChangeLog:
* gcc.target/microblaze/long.c: New test.
---
gcc/ChangeLog | 6 ++++++
gcc/config/microblaze/microblaze.c | 9 ++++++---
gcc/testsuite/ChangeLog | 4 ++++
gcc/testsuite/gcc.target/microblaze/long.c | 10 ++++++++++
4 files changed, 27 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/microblaze/long.c
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1a4c4f6..f28ebf7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-11-09 Nagaraju Mekala <nmekala@xilix.com>
+
+ * config/microblaze/microblaze.c (print_operand): Update loading
+ of DI mode immediate values using REAL_VALUE_FROM_CONST_DOUBLE
+ and REAL_VALUE_TO_TARGET_DOUBLE
+
2020-11-08 David Edelsohn <dje.gcc@gmail.com>
* config/rs6000/rs6000.c (rs6000_mangle_decl_assembler_name): Change
diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index a0f81b7..d9341ec 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -2440,15 +2440,18 @@ print_operand (FILE * file, rtx op, int letter)
else if (letter == 'h' || letter == 'j')
{
- long val[2];
+ long val[2], l[2];
if (code == CONST_DOUBLE)
{
if (GET_MODE (op) == DFmode)
REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
else
{
- val[0] = CONST_DOUBLE_HIGH (op);
- val[1] = CONST_DOUBLE_LOW (op);
+ REAL_VALUE_TYPE rv;
+ REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
+ REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
+ val[1] = l[WORDS_BIG_ENDIAN == 0];
+ val[0] = l[WORDS_BIG_ENDIAN != 0];
}
}
else if (code == CONST_INT)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cff8ccf..081be8f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-09 Nagaraju Mekala <nmekala@xilinx.com>
+
+ * gcc.target/microblaze/long.c: New test.
+
2020-11-08 Iain Sandoe <iain@sandoe.co.uk>
* obj-c++.dg/property/at-property-4.mm: Test handling class
diff --git a/gcc/testsuite/gcc.target/microblaze/long.c b/gcc/testsuite/gcc.target/microblaze/long.c
new file mode 100644
index 0000000..4d45186
--- /dev/null
+++ b/gcc/testsuite/gcc.target/microblaze/long.c
@@ -0,0 +1,10 @@
+/* { dg-options "-O0" } */
+#define BASEADDR 0xF0000000ULL
+int main ()
+{
+ unsigned long long start;
+ start = (unsigned long long) BASEADDR;
+ return 0;
+}
+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0x00000000" } } */
+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0xf0000000" } } */
--
1.8.3.1
Attached is the patch.
Thanks,
Nagaraju
[-- Attachment #2: 0001-Patch-microblaze-Correct-the-const-high-double-immed.patch --]
[-- Type: application/octet-stream, Size: 3378 bytes --]
From d47fcdb47569706d673af8e76fb2752b57bd57e7 Mon Sep 17 00:00:00 2001
From: Nagaraju Mekala <nmekala@xilinx.com>
Date: Mon, 9 Nov 2020 10:44:04 +0530
Subject: [PATCH] [Patch, microblaze]: Correct the const high double immediate
value This patch will load the DI mode immediate values from
REAL_VALUE_FROM_CONST_DOUBLE and REAL_VALUE_TO_TARGET_DOUBLE functions, as
CONST_DOUBLE_HIGH was returning the sign extension value even for the
unsigned long long constants also
gcc/ChangeLog:
* config/microblaze/microblaze.c (print_operand): Update
loading of DI mode immediate values using
REAL_VALUE_FROM_CONST_DOUBLE and
REAL_VALUE_TO_TARGET_DOUBLE
gcc/testsuite/ChangeLog:
* gcc.target/microblaze/long.c: New test.
---
gcc/ChangeLog | 6 ++++++
gcc/config/microblaze/microblaze.c | 9 ++++++---
gcc/testsuite/ChangeLog | 4 ++++
gcc/testsuite/gcc.target/microblaze/long.c | 10 ++++++++++
4 files changed, 27 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/microblaze/long.c
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1a4c4f6..f28ebf7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2020-11-09 Nagaraju Mekala <nmekala@xilix.com>
+
+ * config/microblaze/microblaze.c (print_operand): Update loading
+ of DI mode immediate values using REAL_VALUE_FROM_CONST_DOUBLE
+ and REAL_VALUE_TO_TARGET_DOUBLE
+
2020-11-08 David Edelsohn <dje.gcc@gmail.com>
* config/rs6000/rs6000.c (rs6000_mangle_decl_assembler_name): Change
diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c
index a0f81b7..d9341ec 100644
--- a/gcc/config/microblaze/microblaze.c
+++ b/gcc/config/microblaze/microblaze.c
@@ -2440,15 +2440,18 @@ print_operand (FILE * file, rtx op, int letter)
else if (letter == 'h' || letter == 'j')
{
- long val[2];
+ long val[2], l[2];
if (code == CONST_DOUBLE)
{
if (GET_MODE (op) == DFmode)
REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op), val);
else
{
- val[0] = CONST_DOUBLE_HIGH (op);
- val[1] = CONST_DOUBLE_LOW (op);
+ REAL_VALUE_TYPE rv;
+ REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
+ REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
+ val[1] = l[WORDS_BIG_ENDIAN == 0];
+ val[0] = l[WORDS_BIG_ENDIAN != 0];
}
}
else if (code == CONST_INT)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cff8ccf..081be8f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-09 Nagaraju Mekala <nmekala@xilinx.com>
+
+ * gcc.target/microblaze/long.c: New test.
+
2020-11-08 Iain Sandoe <iain@sandoe.co.uk>
* obj-c++.dg/property/at-property-4.mm: Test handling class
diff --git a/gcc/testsuite/gcc.target/microblaze/long.c b/gcc/testsuite/gcc.target/microblaze/long.c
new file mode 100644
index 0000000..4d45186
--- /dev/null
+++ b/gcc/testsuite/gcc.target/microblaze/long.c
@@ -0,0 +1,10 @@
+/* { dg-options "-O0" } */
+#define BASEADDR 0xF0000000ULL
+int main ()
+{
+ unsigned long long start;
+ start = (unsigned long long) BASEADDR;
+ return 0;
+}
+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0x00000000" } } */
+/* { dg-final { scan-assembler "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0xf0000000" } } */
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Patch, microblaze]: Correct the const high double immediate value
2020-11-09 5:43 [Patch, microblaze]: Correct the const high double immediate value Nagaraju Mekala
@ 2020-11-11 3:36 ` Michael Eager
2020-11-11 17:42 ` Nagaraju Mekala
0 siblings, 1 reply; 3+ messages in thread
From: Michael Eager @ 2020-11-11 3:36 UTC (permalink / raw)
To: Nagaraju Mekala, Michael Eager, gcc-patches; +Cc: Sadanand Mutyala
On 11/8/20 9:43 PM, Nagaraju Mekala wrote:
> diff --git a/gcc/config/microblaze/microblaze.c
> b/gcc/config/microblaze/microblaze.c
>
> index a0f81b7..d9341ec 100644
> --- a/gcc/config/microblaze/microblaze.c
> +++ b/gcc/config/microblaze/microblaze.c
> @@ -2440,15 +2440,18 @@ print_operand (FILE * file, rtx op, int letter)
> else if (letter == 'h' || letter == 'j')
> {
> - long val[2];
> + long val[2], l[2];
> if (code == CONST_DOUBLE)
> {
> if (GET_MODE (op) == DFmode)
> REAL_VALUE_TO_TARGET_DOUBLE (*CONST_DOUBLE_REAL_VALUE (op),
> val);
> else
> {
> - val[0] = CONST_DOUBLE_HIGH (op);
> - val[1] = CONST_DOUBLE_LOW (op);
> + REAL_VALUE_TYPE rv;
> + REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
REAL_VALUE_FROM_CONST_DOUBLE was removed from real.h in 2015.
Use CONST_DOUBLE_REAL_VALUE.
> + REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
> + val[1] = l[WORDS_BIG_ENDIAN == 0];
> + val[0] = l[WORDS_BIG_ENDIAN != 0];
> }
> }
> else if (code == CONST_INT)
> diff --git a/gcc/testsuite/gcc.target/microblaze/long.c
> b/gcc/testsuite/gcc.target/microblaze/long.c
> new file mode 100644
> index 0000000..4d45186
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/microblaze/long.c
> @@ -0,0 +1,10 @@
> +/* { dg-options "-O0" } */
> +#define BASEADDR 0xF0000000ULL
> +int main ()
> +{
> + unsigned long long start;
> + start = (unsigned long long) BASEADDR;
> + return 0;
> +}
> +/* { dg-final { scan-assembler
> "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0x00000000" } } */
> +/* { dg-final { scan-assembler
> "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0xf0000000" } } */
It looks like this test case will pass without the patch. The code
generated before applying the patch is
addik r4,r0,0x00000000
addik r5,r0,0xf0000000 #li => la
Can you provide a test case which fails without the patch but passes
with the patch?
--
Michael Eager
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: [Patch, microblaze]: Correct the const high double immediate value
2020-11-11 3:36 ` Michael Eager
@ 2020-11-11 17:42 ` Nagaraju Mekala
0 siblings, 0 replies; 3+ messages in thread
From: Nagaraju Mekala @ 2020-11-11 17:42 UTC (permalink / raw)
To: Michael Eager, gcc-patches; +Cc: Sadanand Mutyala
Hi Eager,
> -----Original Message-----
> From: Michael Eager <eager@eagercon.com>
> Sent: Wednesday, November 11, 2020 9:06 AM
> To: Nagaraju Mekala <nmekala@xilinx.com>; Michael Eager
> <eager@eagercon.com>; gcc-patches@gcc.gnu.org
> Cc: Sadanand Mutyala <sadanan@xilinx.com>
> Subject: Re: [Patch, microblaze]: Correct the const high double immediate
> value
>
> On 11/8/20 9:43 PM, Nagaraju Mekala wrote:
> > diff --git a/gcc/config/microblaze/microblaze.c
> > b/gcc/config/microblaze/microblaze.c
> >
> > index a0f81b7..d9341ec 100644
> > --- a/gcc/config/microblaze/microblaze.c
> > +++ b/gcc/config/microblaze/microblaze.c
> > @@ -2440,15 +2440,18 @@ print_operand (FILE * file, rtx op, int
> > letter)
> > else if (letter == 'h' || letter == 'j')
> > {
> > - long val[2];
> > + long val[2], l[2];
> > if (code == CONST_DOUBLE)
> > {
> > if (GET_MODE (op) == DFmode)
> > REAL_VALUE_TO_TARGET_DOUBLE
> (*CONST_DOUBLE_REAL_VALUE
> > (op), val);
> > else
> > {
> > - val[0] = CONST_DOUBLE_HIGH (op);
> > - val[1] = CONST_DOUBLE_LOW (op);
> > + REAL_VALUE_TYPE rv;
> > + REAL_VALUE_FROM_CONST_DOUBLE (rv, op);
>
> REAL_VALUE_FROM_CONST_DOUBLE was removed from real.h in 2015.
> Use CONST_DOUBLE_REAL_VALUE.
>
> > + REAL_VALUE_TO_TARGET_DOUBLE (rv, l);
> > + val[1] = l[WORDS_BIG_ENDIAN == 0];
> > + val[0] = l[WORDS_BIG_ENDIAN != 0];
> > }
> > }
> > else if (code == CONST_INT)
>
>
> > diff --git a/gcc/testsuite/gcc.target/microblaze/long.c
> > b/gcc/testsuite/gcc.target/microblaze/long.c
> > new file mode 100644
> > index 0000000..4d45186
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/microblaze/long.c
> > @@ -0,0 +1,10 @@
> > +/* { dg-options "-O0" } */
> > +#define BASEADDR 0xF0000000ULL
> > +int main ()
> > +{
> > + unsigned long long start;
> > + start = (unsigned long long) BASEADDR;
> > + return 0;
> > +}
> > +/* { dg-final { scan-assembler
> > "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0x00000000" } } */
> > +/* { dg-final { scan-assembler
> > "addik\tr(\[0-9]\|\[1-2]\[0-9]\|3\[0-1]),r0,0xf0000000" } } */
>
> It looks like this test case will pass without the patch. The code
> generated before applying the patch is
> addik r4,r0,0x00000000
> addik r5,r0,0xf0000000 #li => la
>
> Can you provide a test case which fails without the patch but passes
> with the patch?
Thanks for reviewing the patch, I will update both patch and testcase and re-submit them.
Thanks,
Nagaraju
>
> --
> Michael Eager
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-11-11 17:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-09 5:43 [Patch, microblaze]: Correct the const high double immediate value Nagaraju Mekala
2020-11-11 3:36 ` Michael Eager
2020-11-11 17:42 ` Nagaraju Mekala
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).