]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
powerpc: Fix ICE with fp conditional move (PR target/93073)
authorJakub Jelinek <jakub@redhat.com>
Fri, 14 Feb 2020 14:40:34 +0000 (15:40 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 14 Feb 2020 15:01:46 +0000 (16:01 +0100)
The following testcase ICEs, because for TFmode the particular subtraction
pattern (*subtf3) is not enabled with the given options.  Using
expand_simple_binop instead of emitting the subtraction by hand just moves
the ICE one insn later, NEG of ABS is not then recognized, etc., but
ultimately the problem is that when rs6000_emit_cmove is called for floating
point operand mode (and earlier condition ensures that in that case
compare_mode is also floating point), the expander makes sure the
operand mode is SFDF, but for the comparison mode nothing checks it, yet
there is just one *fsel* pattern with 2 separate SFDF iterators.

The following patch fixes it by giving up if compare_mode is not SFmode or
DFmode.

2020-01-21  Jakub Jelinek  <jakub@redhat.com>

PR target/93073
* config/rs6000/rs6000.c (rs6000_emit_cmove): If using fsel, punt for
compare_mode other than SFmode or DFmode.

* gcc.target/powerpc/pr93073.c: New test.

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr93073.c [new file with mode: 0644]

index e17c88b2166bb23782208e62da52e24a0537a4e4..9437e2eb2fc66a528c5176bd355f8eda4dc6772d 100644 (file)
@@ -1,6 +1,12 @@
 2020-02-14  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2020-01-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/93073
+       * config/rs6000/rs6000.c (rs6000_emit_cmove): If using fsel, punt for
+       compare_mode other than SFmode or DFmode.
+
        2020-01-09  Jakub Jelinek  <jakub@redhat.com>
 
        PR inline-asm/93202
index ea43713ce0154ae78790b966941565bb24872b7c..8cf6bd54b2f605e5812df3ae3d50422b22c90aea 100644 (file)
@@ -23551,6 +23551,11 @@ rs6000_emit_cmove (rtx dest, rtx op, rtx true_cond, rtx false_cond)
 
   /* At this point we know we can use fsel.  */
 
+  /* Don't allow compare_mode other than SFmode or DFmode, for others there
+     is no fsel instruction.  */
+  if (compare_mode != SFmode && compare_mode != DFmode)
+    return 0;
+
   /* Reduce the comparison to a comparison against zero.  */
   if (! is_against_zero)
     {
index dd021d1980c535551bf8bdbc778d5b5391d4cae4..381ce4f45835458072d07ba7a3a4c6049bd5a538 100644 (file)
@@ -1,6 +1,11 @@
 2020-02-14  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2020-01-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR target/93073
+       * gcc.target/powerpc/pr93073.c: New test.
+
        2020-01-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/93228
diff --git a/gcc/testsuite/gcc.target/powerpc/pr93073.c b/gcc/testsuite/gcc.target/powerpc/pr93073.c
new file mode 100644 (file)
index 0000000..6a0a473
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR target/93073 */
+/* { dg-do compile { target powerpc_vsx_ok } } */
+/* { dg-options "-mvsx -O1 -ffinite-math-only -fno-trapping-math" } */
+
+void bar (void);
+
+void
+foo (long double x, double y, double z)
+{
+  for (;;)
+    {
+      double a = x > 0.0 ? y : z;
+      if (a == 0.0)
+       bar ();
+    }
+}