s390x: Fix PR112753

Message ID 20231130154547.17694-1-jchrist@linux.ibm.com
State Accepted
Headers
Series s390x: Fix PR112753 |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Juergen Christ Nov. 30, 2023, 3:45 p.m. UTC
  Commit 466b100e5fee808d77598e0f294654deec281150 introduced a bug in
s390_md_asm_adjust if vector extensions are not available.  Fix the control
flow of this function to not adjust long double values.

gcc/ChangeLog:

	* config/s390/s390.cc (s390_md_asm_adjust): Fix.

gcc/testsuite/ChangeLog:

	* gcc.target/s390/pr112753.c: New test.

Bootstrapped and tested on s390x.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
---
 gcc/config/s390/s390.cc                  | 4 ++++
 gcc/testsuite/gcc.target/s390/pr112753.c | 8 ++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/s390/pr112753.c
  

Comments

Andreas Krebbel Dec. 1, 2023, 7:20 a.m. UTC | #1
On 11/30/23 16:45, Juergen Christ wrote:
> Commit 466b100e5fee808d77598e0f294654deec281150 introduced a bug in
> s390_md_asm_adjust if vector extensions are not available.  Fix the control
> flow of this function to not adjust long double values.
> 
> gcc/ChangeLog:
> 
> 	* config/s390/s390.cc (s390_md_asm_adjust): Fix.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* gcc.target/s390/pr112753.c: New test.
> 
> Bootstrapped and tested on s390x.

Committed to mainline with a slightly more verbose changelog which also refers to the BZ. Thanks!

Andreas

> 
> Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
> ---
>  gcc/config/s390/s390.cc                  | 4 ++++
>  gcc/testsuite/gcc.target/s390/pr112753.c | 8 ++++++++
>  2 files changed, 12 insertions(+)
>  create mode 100644 gcc/testsuite/gcc.target/s390/pr112753.c
> 
> diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
> index 29b5dc979207..3a4d2d346f0c 100644
> --- a/gcc/config/s390/s390.cc
> +++ b/gcc/config/s390/s390.cc
> @@ -17604,6 +17604,10 @@ s390_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &inputs,
>        outputs[i] = fprx2;
>      }
>  
> +  if (!TARGET_VXE)
> +    /* Long doubles are stored in FPR pairs - nothing left to do.  */
> +    return after_md_seq;
> +
>    for (unsigned i = 0; i < ninputs; i++)
>      {
>        if (GET_MODE (inputs[i]) != TFmode)
> diff --git a/gcc/testsuite/gcc.target/s390/pr112753.c b/gcc/testsuite/gcc.target/s390/pr112753.c
> new file mode 100644
> index 000000000000..7183b3f12bed
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/s390/pr112753.c
> @@ -0,0 +1,8 @@
> +/* This caused an ICE on s390x due to a bug in s390_md_asm_adjust when no
> +   vector extension is available.  */
> +
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -march=zEC12" } */
> +
> +long double ____strtold_l_internal___x;
> +void ____strtold_l_internal() { __asm__("" : : "fm"(____strtold_l_internal___x)); }
  

Patch

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index 29b5dc979207..3a4d2d346f0c 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -17604,6 +17604,10 @@  s390_md_asm_adjust (vec<rtx> &outputs, vec<rtx> &inputs,
       outputs[i] = fprx2;
     }
 
+  if (!TARGET_VXE)
+    /* Long doubles are stored in FPR pairs - nothing left to do.  */
+    return after_md_seq;
+
   for (unsigned i = 0; i < ninputs; i++)
     {
       if (GET_MODE (inputs[i]) != TFmode)
diff --git a/gcc/testsuite/gcc.target/s390/pr112753.c b/gcc/testsuite/gcc.target/s390/pr112753.c
new file mode 100644
index 000000000000..7183b3f12bed
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr112753.c
@@ -0,0 +1,8 @@ 
+/* This caused an ICE on s390x due to a bug in s390_md_asm_adjust when no
+   vector extension is available.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=zEC12" } */
+
+long double ____strtold_l_internal___x;
+void ____strtold_l_internal() { __asm__("" : : "fm"(____strtold_l_internal___x)); }