public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] bpf: correct bpf_print_operand for floats [PR108293]
@ 2023-01-09 22:40 David Faust
  2023-01-10  9:59 ` Jose E. Marchesi
  0 siblings, 1 reply; 4+ messages in thread
From: David Faust @ 2023-01-09 22:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: jose.marchesi

The existing logic in bpf_print_operand was only correct for integral
CONST_DOUBLEs, and emitted garbage for floating point modes. Fix it so
floating point mode operands are correctly handled.

Tested on bpf-unknown-none, no known regressions.
OK to check-in?

Thanks.


	PR target/108293

gcc/

	* config/bpf/bpf.cc (bpf_print_operand): Correct handling for
	floating point modes.

gcc/testsuite/

	* gcc.target/bpf/double-1.c: New test.
	* gcc.target/bpf/double-2.c: New test.
	* gcc.target/bpf/float-1.c: New test.
---
 gcc/config/bpf/bpf.cc                   | 21 ++++++++++++++-------
 gcc/testsuite/gcc.target/bpf/double-1.c | 12 ++++++++++++
 gcc/testsuite/gcc.target/bpf/double-2.c | 12 ++++++++++++
 gcc/testsuite/gcc.target/bpf/float-1.c  | 12 ++++++++++++
 4 files changed, 50 insertions(+), 7 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/bpf/double-1.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/double-2.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/float-1.c

diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 2aeaeaf309b..9dde3944e9c 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -880,13 +880,20 @@ bpf_print_operand (FILE *file, rtx op, int code ATTRIBUTE_UNUSED)
       output_address (GET_MODE (op), XEXP (op, 0));
       break;
     case CONST_DOUBLE:
-      if (CONST_DOUBLE_HIGH (op))
-	fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
-		 CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
-      else if (CONST_DOUBLE_LOW (op) < 0)
-	fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
-      else
-	fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
+      long vals[2];
+      real_to_target (vals, CONST_DOUBLE_REAL_VALUE (op), GET_MODE (op));
+      vals[0] &= 0xffffffff;
+      vals[1] &= 0xffffffff;
+      if (GET_MODE (op) == SFmode)
+	fprintf (file, "0x%08lx", vals[0]);
+      else if (GET_MODE (op) == DFmode)
+	{
+	  /* Note: real_to_target puts vals in target word order.  */
+	  if (WORDS_BIG_ENDIAN)
+	    fprintf (file, "0x%08lx%08lx", vals[0], vals[1]);
+	  else
+	    fprintf (file, "0x%08lx%08lx", vals[1], vals[0]);
+	}
       break;
     default:
       output_addr_const (file, op);
diff --git a/gcc/testsuite/gcc.target/bpf/double-1.c b/gcc/testsuite/gcc.target/bpf/double-1.c
new file mode 100644
index 00000000000..200f1bd18f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/double-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mlittle-endian" } */
+
+double f;
+double a() { f = 1.0; return 1.0; }
+double b() { f = 2.0; return 2.0; }
+double c() { f = 2.0; return 3.0; }
+double d() { f = 3.0; return 3.0; }
+
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
diff --git a/gcc/testsuite/gcc.target/bpf/double-2.c b/gcc/testsuite/gcc.target/bpf/double-2.c
new file mode 100644
index 00000000000..d04ddd0c575
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/double-2.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mbig-endian" } */
+
+double f;
+double a() { f = 1.0; return 1.0; }
+double b() { f = 2.0; return 2.0; }
+double c() { f = 2.0; return 3.0; }
+double d() { f = 3.0; return 3.0; }
+
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
diff --git a/gcc/testsuite/gcc.target/bpf/float-1.c b/gcc/testsuite/gcc.target/bpf/float-1.c
new file mode 100644
index 00000000000..05ed7bb651d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/float-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mlittle-endian" } */
+
+float f;
+float a() { f = 1.0; return 1.0; }
+float b() { f = 2.0; return 2.0; }
+float c() { f = 2.0; return 3.0; }
+float d() { f = 3.0; return 3.0; }
+
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x3f800000" 2 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x40000000" 3 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x40400000" 3 } } */
-- 
2.39.0


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

* Re: [PATCH] bpf: correct bpf_print_operand for floats [PR108293]
  2023-01-09 22:40 [PATCH] bpf: correct bpf_print_operand for floats [PR108293] David Faust
@ 2023-01-10  9:59 ` Jose E. Marchesi
  2023-01-10 19:12   ` [PATCH v2] " David Faust
  0 siblings, 1 reply; 4+ messages in thread
From: Jose E. Marchesi @ 2023-01-10  9:59 UTC (permalink / raw)
  To: David Faust; +Cc: gcc-patches


Hi David.
Thanks for the patch.

> diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
> index 2aeaeaf309b..9dde3944e9c 100644
> --- a/gcc/config/bpf/bpf.cc
> +++ b/gcc/config/bpf/bpf.cc
> @@ -880,13 +880,20 @@ bpf_print_operand (FILE *file, rtx op, int code ATTRIBUTE_UNUSED)
>        output_address (GET_MODE (op), XEXP (op, 0));
>        break;
>      case CONST_DOUBLE:
> -      if (CONST_DOUBLE_HIGH (op))
> -	fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
> -		 CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
> -      else if (CONST_DOUBLE_LOW (op) < 0)
> -	fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
> -      else
> -	fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
> +      long vals[2];
> +      real_to_target (vals, CONST_DOUBLE_REAL_VALUE (op), GET_MODE (op));
> +      vals[0] &= 0xffffffff;
> +      vals[1] &= 0xffffffff;
> +      if (GET_MODE (op) == SFmode)
> +	fprintf (file, "0x%08lx", vals[0]);
> +      else if (GET_MODE (op) == DFmode)
> +	{
> +	  /* Note: real_to_target puts vals in target word order.  */
> +	  if (WORDS_BIG_ENDIAN)
> +	    fprintf (file, "0x%08lx%08lx", vals[0], vals[1]);
> +	  else
> +	    fprintf (file, "0x%08lx%08lx", vals[1], vals[0]);
> +	}
>        break;
>      default:
>        output_addr_const (file, op);

Do we want a gcc_unreachable in case the mode of `op' is not SFmode nor
DFmode?

> diff --git a/gcc/testsuite/gcc.target/bpf/double-1.c b/gcc/testsuite/gcc.target/bpf/double-1.c
> new file mode 100644
> index 00000000000..200f1bd18f8
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/bpf/double-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mlittle-endian" } */
> +
> +double f;
> +double a() { f = 1.0; return 1.0; }
> +double b() { f = 2.0; return 2.0; }
> +double c() { f = 2.0; return 3.0; }
> +double d() { f = 3.0; return 3.0; }
> +
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
> diff --git a/gcc/testsuite/gcc.target/bpf/double-2.c b/gcc/testsuite/gcc.target/bpf/double-2.c
> new file mode 100644
> index 00000000000..d04ddd0c575
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/bpf/double-2.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mbig-endian" } */
> +
> +double f;
> +double a() { f = 1.0; return 1.0; }
> +double b() { f = 2.0; return 2.0; }
> +double c() { f = 2.0; return 3.0; }
> +double d() { f = 3.0; return 3.0; }
> +
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
> diff --git a/gcc/testsuite/gcc.target/bpf/float-1.c b/gcc/testsuite/gcc.target/bpf/float-1.c
> new file mode 100644
> index 00000000000..05ed7bb651d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/bpf/float-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mlittle-endian" } */
> +
> +float f;
> +float a() { f = 1.0; return 1.0; }
> +float b() { f = 2.0; return 2.0; }
> +float c() { f = 2.0; return 3.0; }
> +float d() { f = 3.0; return 3.0; }
> +
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x3f800000" 2 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x40000000" 3 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x40400000" 3 } } */

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

* [PATCH v2] bpf: correct bpf_print_operand for floats [PR108293]
  2023-01-10  9:59 ` Jose E. Marchesi
@ 2023-01-10 19:12   ` David Faust
  2023-01-10 23:57     ` Jose E. Marchesi
  0 siblings, 1 reply; 4+ messages in thread
From: David Faust @ 2023-01-10 19:12 UTC (permalink / raw)
  To: jose.marchesi; +Cc: gcc-patches

Hi Jose,

As we discussed on IRC, since we don't currently define
TARGET_SUPPORTS_WIDE_INT it is safer to keep the handling for VOIDmode
CONST_DOUBLEs. My current understanding is that it may be needed if the
host is a 32-bit platform.

I also added a gcc_unreachable () as you pointed out. V2 below.
Tested with bpf-unknown-none on x86_64 host, no known regressions.

WDYT?

Thanks,
David

---

[Changes from v1:
 - Keep handling for VOIDmode CONST_DOUBLE, just in case.
 - Add a gcc_unreachable () if `op` is none of VOIDmode, SFmode,
   nor DFmode. ]

The existing logic in bpf_print_operand was only correct for integral
CONST_DOUBLEs, and emitted garbage for floating point modes. Fix it so
floating point mode operands are correctly handled.

	PR target/108293

gcc/

	* config/bpf/bpf.cc (bpf_print_operand): Correct handling for
	floating point modes.

gcc/testsuite/

	* gcc.target/bpf/double-1.c: New test.
	* gcc.target/bpf/double-2.c: New test.
	* gcc.target/bpf/float-1.c: New test.
---
 gcc/config/bpf/bpf.cc                   | 34 ++++++++++++++++++++-----
 gcc/testsuite/gcc.target/bpf/double-1.c | 12 +++++++++
 gcc/testsuite/gcc.target/bpf/double-2.c | 12 +++++++++
 gcc/testsuite/gcc.target/bpf/float-1.c  | 12 +++++++++
 4 files changed, 64 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/bpf/double-1.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/double-2.c
 create mode 100644 gcc/testsuite/gcc.target/bpf/float-1.c

diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
index 2aeaeaf309b..576a1fe8eab 100644
--- a/gcc/config/bpf/bpf.cc
+++ b/gcc/config/bpf/bpf.cc
@@ -880,13 +880,35 @@ bpf_print_operand (FILE *file, rtx op, int code ATTRIBUTE_UNUSED)
       output_address (GET_MODE (op), XEXP (op, 0));
       break;
     case CONST_DOUBLE:
-      if (CONST_DOUBLE_HIGH (op))
-	fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
-		 CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
-      else if (CONST_DOUBLE_LOW (op) < 0)
-	fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
+      if (GET_MODE (op) == VOIDmode)
+	{
+	  if (CONST_DOUBLE_HIGH (op))
+	    fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
+		     CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
+	  else if (CONST_DOUBLE_LOW (op) < 0)
+	    fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
+	  else
+	    fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
+	}
       else
-	fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
+	{
+	  long vals[2];
+	  real_to_target (vals, CONST_DOUBLE_REAL_VALUE (op), GET_MODE (op));
+	  vals[0] &= 0xffffffff;
+	  vals[1] &= 0xffffffff;
+	  if (GET_MODE (op) == SFmode)
+	    fprintf (file, "0x%08lx", vals[0]);
+	  else if (GET_MODE (op) == DFmode)
+	    {
+	      /* Note: real_to_target puts vals in target word order.  */
+	      if (WORDS_BIG_ENDIAN)
+		fprintf (file, "0x%08lx%08lx", vals[0], vals[1]);
+	      else
+		fprintf (file, "0x%08lx%08lx", vals[1], vals[0]);
+	    }
+	  else
+	    gcc_unreachable ();
+	}
       break;
     default:
       output_addr_const (file, op);
diff --git a/gcc/testsuite/gcc.target/bpf/double-1.c b/gcc/testsuite/gcc.target/bpf/double-1.c
new file mode 100644
index 00000000000..200f1bd18f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/double-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mlittle-endian" } */
+
+double f;
+double a() { f = 1.0; return 1.0; }
+double b() { f = 2.0; return 2.0; }
+double c() { f = 2.0; return 3.0; }
+double d() { f = 3.0; return 3.0; }
+
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
diff --git a/gcc/testsuite/gcc.target/bpf/double-2.c b/gcc/testsuite/gcc.target/bpf/double-2.c
new file mode 100644
index 00000000000..d04ddd0c575
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/double-2.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mbig-endian" } */
+
+double f;
+double a() { f = 1.0; return 1.0; }
+double b() { f = 2.0; return 2.0; }
+double c() { f = 2.0; return 3.0; }
+double d() { f = 3.0; return 3.0; }
+
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
diff --git a/gcc/testsuite/gcc.target/bpf/float-1.c b/gcc/testsuite/gcc.target/bpf/float-1.c
new file mode 100644
index 00000000000..05ed7bb651d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/bpf/float-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-mlittle-endian" } */
+
+float f;
+float a() { f = 1.0; return 1.0; }
+float b() { f = 2.0; return 2.0; }
+float c() { f = 2.0; return 3.0; }
+float d() { f = 3.0; return 3.0; }
+
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x3f800000" 2 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x40000000" 3 } } */
+/* { dg-final { scan-assembler-times "lddw\t%r.,0x40400000" 3 } } */
-- 
2.39.0


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

* Re: [PATCH v2] bpf: correct bpf_print_operand for floats [PR108293]
  2023-01-10 19:12   ` [PATCH v2] " David Faust
@ 2023-01-10 23:57     ` Jose E. Marchesi
  0 siblings, 0 replies; 4+ messages in thread
From: Jose E. Marchesi @ 2023-01-10 23:57 UTC (permalink / raw)
  To: David Faust; +Cc: gcc-patches


> Hi Jose,
>
> As we discussed on IRC, since we don't currently define
> TARGET_SUPPORTS_WIDE_INT it is safer to keep the handling for VOIDmode
> CONST_DOUBLEs. My current understanding is that it may be needed if the
> host is a 32-bit platform.
>
> I also added a gcc_unreachable () as you pointed out. V2 below.
> Tested with bpf-unknown-none on x86_64 host, no known regressions.
>
> WDYT?

OK for master.
Thanks!

>
> Thanks,
> David
>
> ---
>
> [Changes from v1:
>  - Keep handling for VOIDmode CONST_DOUBLE, just in case.
>  - Add a gcc_unreachable () if `op` is none of VOIDmode, SFmode,
>    nor DFmode. ]
>
> The existing logic in bpf_print_operand was only correct for integral
> CONST_DOUBLEs, and emitted garbage for floating point modes. Fix it so
> floating point mode operands are correctly handled.
>
> 	PR target/108293
>
> gcc/
>
> 	* config/bpf/bpf.cc (bpf_print_operand): Correct handling for
> 	floating point modes.
>
> gcc/testsuite/
>
> 	* gcc.target/bpf/double-1.c: New test.
> 	* gcc.target/bpf/double-2.c: New test.
> 	* gcc.target/bpf/float-1.c: New test.
> ---
>  gcc/config/bpf/bpf.cc                   | 34 ++++++++++++++++++++-----
>  gcc/testsuite/gcc.target/bpf/double-1.c | 12 +++++++++
>  gcc/testsuite/gcc.target/bpf/double-2.c | 12 +++++++++
>  gcc/testsuite/gcc.target/bpf/float-1.c  | 12 +++++++++
>  4 files changed, 64 insertions(+), 6 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/bpf/double-1.c
>  create mode 100644 gcc/testsuite/gcc.target/bpf/double-2.c
>  create mode 100644 gcc/testsuite/gcc.target/bpf/float-1.c
>
> diff --git a/gcc/config/bpf/bpf.cc b/gcc/config/bpf/bpf.cc
> index 2aeaeaf309b..576a1fe8eab 100644
> --- a/gcc/config/bpf/bpf.cc
> +++ b/gcc/config/bpf/bpf.cc
> @@ -880,13 +880,35 @@ bpf_print_operand (FILE *file, rtx op, int code ATTRIBUTE_UNUSED)
>        output_address (GET_MODE (op), XEXP (op, 0));
>        break;
>      case CONST_DOUBLE:
> -      if (CONST_DOUBLE_HIGH (op))
> -	fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
> -		 CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
> -      else if (CONST_DOUBLE_LOW (op) < 0)
> -	fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
> +      if (GET_MODE (op) == VOIDmode)
> +	{
> +	  if (CONST_DOUBLE_HIGH (op))
> +	    fprintf (file, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
> +		     CONST_DOUBLE_HIGH (op), CONST_DOUBLE_LOW (op));
> +	  else if (CONST_DOUBLE_LOW (op) < 0)
> +	    fprintf (file, HOST_WIDE_INT_PRINT_HEX, CONST_DOUBLE_LOW (op));
> +	  else
> +	    fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
> +	}
>        else
> -	fprintf (file, HOST_WIDE_INT_PRINT_DEC, CONST_DOUBLE_LOW (op));
> +	{
> +	  long vals[2];
> +	  real_to_target (vals, CONST_DOUBLE_REAL_VALUE (op), GET_MODE (op));
> +	  vals[0] &= 0xffffffff;
> +	  vals[1] &= 0xffffffff;
> +	  if (GET_MODE (op) == SFmode)
> +	    fprintf (file, "0x%08lx", vals[0]);
> +	  else if (GET_MODE (op) == DFmode)
> +	    {
> +	      /* Note: real_to_target puts vals in target word order.  */
> +	      if (WORDS_BIG_ENDIAN)
> +		fprintf (file, "0x%08lx%08lx", vals[0], vals[1]);
> +	      else
> +		fprintf (file, "0x%08lx%08lx", vals[1], vals[0]);
> +	    }
> +	  else
> +	    gcc_unreachable ();
> +	}
>        break;
>      default:
>        output_addr_const (file, op);
> diff --git a/gcc/testsuite/gcc.target/bpf/double-1.c b/gcc/testsuite/gcc.target/bpf/double-1.c
> new file mode 100644
> index 00000000000..200f1bd18f8
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/bpf/double-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mlittle-endian" } */
> +
> +double f;
> +double a() { f = 1.0; return 1.0; }
> +double b() { f = 2.0; return 2.0; }
> +double c() { f = 2.0; return 3.0; }
> +double d() { f = 3.0; return 3.0; }
> +
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
> diff --git a/gcc/testsuite/gcc.target/bpf/double-2.c b/gcc/testsuite/gcc.target/bpf/double-2.c
> new file mode 100644
> index 00000000000..d04ddd0c575
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/bpf/double-2.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mbig-endian" } */
> +
> +double f;
> +double a() { f = 1.0; return 1.0; }
> +double b() { f = 2.0; return 2.0; }
> +double c() { f = 2.0; return 3.0; }
> +double d() { f = 3.0; return 3.0; }
> +
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x3ff0000000000000" 2 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4000000000000000" 3 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x4008000000000000" 3 } } */
> diff --git a/gcc/testsuite/gcc.target/bpf/float-1.c b/gcc/testsuite/gcc.target/bpf/float-1.c
> new file mode 100644
> index 00000000000..05ed7bb651d
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/bpf/float-1.c
> @@ -0,0 +1,12 @@
> +/* { dg-do compile } */
> +/* { dg-options "-mlittle-endian" } */
> +
> +float f;
> +float a() { f = 1.0; return 1.0; }
> +float b() { f = 2.0; return 2.0; }
> +float c() { f = 2.0; return 3.0; }
> +float d() { f = 3.0; return 3.0; }
> +
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x3f800000" 2 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x40000000" 3 } } */
> +/* { dg-final { scan-assembler-times "lddw\t%r.,0x40400000" 3 } } */

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

end of thread, other threads:[~2023-01-10 23:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-09 22:40 [PATCH] bpf: correct bpf_print_operand for floats [PR108293] David Faust
2023-01-10  9:59 ` Jose E. Marchesi
2023-01-10 19:12   ` [PATCH v2] " David Faust
2023-01-10 23:57     ` Jose E. Marchesi

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