]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PATCH] [PR rtl-optimization/49847] Fix ICE in CSE due to cc0-setter and cc0-user...
authorJeff Law <law@redhat.com>
Fri, 18 Dec 2015 17:17:14 +0000 (10:17 -0700)
committerJeff Law <law@gcc.gnu.org>
Fri, 18 Dec 2015 17:17:14 +0000 (10:17 -0700)
PR rtl-optimization/49847
* cse.c (record_jump_equiv): Handle fold_rtx returning NULL_RTX.

PR rtl-optimization/49847
* g++.dg/pr49847-2.C: New test.

From-SVN: r231821

gcc/ChangeLog
gcc/cse.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/pr49847-2.C [new file with mode: 0644]

index cb11d02bcce0ede2c997a4e1c742f3de3f621ccc..1caa0760db730ca7377c95e2ac907058bb90734d 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-18  Jeff Law  <law@redhat.com>
+
+       PR rtl-optimization/49847
+       * cse.c (record_jump_equiv): Handle fold_rtx returning NULL_RTX.
+
 2015-12-18  Nathan Sidwell  <nathan@acm.org>
 
        * config/nvptx/nvptx.c (worker_bcast_name, worker_red_name): Delete.
index cb78a95c0b85418fa1a13ea52e9dcc7eceb700bf..4232028f54ff04f43a4eefbba2cb997153a2606b 100644 (file)
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -3874,6 +3874,13 @@ record_jump_equiv (rtx_insn *insn, bool taken)
   op0 = fold_rtx (XEXP (XEXP (SET_SRC (set), 0), 0), insn);
   op1 = fold_rtx (XEXP (XEXP (SET_SRC (set), 0), 1), insn);
 
+  /* On a cc0 target the cc0-setter and cc0-user may end up in different
+     blocks.  When that happens the tracking of the cc0-setter via
+     PREV_INSN_CC0 is spoiled.  That means that fold_rtx may return
+     NULL_RTX.  In those cases, there's nothing to record.  */
+  if (op0 == NULL_RTX || op1 == NULL_RTX)
+    return;
+
   code = find_comparison_args (code, &op0, &op1, &mode0, &mode1);
   if (! cond_known_true)
     {
index 6419d0ee800f70683fe79d81606c6b6d79e48d9f..57326d19ee9c385c88ee3e1d71a7d704c1a593aa 100644 (file)
@@ -1,3 +1,8 @@
+2015-12-18  Jeff Law  <law@redhat.com>
+
+       PR rtl-optimization/49847
+       * g++.dg/pr49847-2.C: New test.
+
 2015-12-18  H.J. Lu  <hongjiu.lu@intel.com>
 
        * gcc.dg/vect/pr68305.c (dg-additional-options): Add -mavx2
diff --git a/gcc/testsuite/g++.dg/pr49847-2.C b/gcc/testsuite/g++.dg/pr49847-2.C
new file mode 100644 (file)
index 0000000..14f1198
--- /dev/null
@@ -0,0 +1,47 @@
+/* { dg-do compile { target m68k-*-* } } */
+/* { dg-options "-O2 -mcpu=68060 -fnon-call-exceptions -fPIC -O2 -fpermissive" } */
+
+extern "C" {
+    typedef __java_int jint;
+    typedef __java_float jfloat;
+    namespace java   {
+     namespace lang     {
+       class Class;
+       class Object;
+       class Throwable;
+   }
+}
+  }
+  typedef class   java::lang::Class *   jclass;
+  typedef   class   java::lang::Throwable *   jthrowable;
+  typedef unsigned short _Jv_ushort __attribute__ ((__mode__ (__HI__)));
+  extern   "Java" {
+    struct _JvObjectPrefix   {
+   };
+  }
+  class   java::lang::Object:   public   _JvObjectPrefix {
+  };
+   union _Jv_word {
+    jint     i;
+    jfloat     f;
+  };
+  class _Jv_MethodBase {
+  };
+   class _Jv_InterpMethod: public _Jv_MethodBase {
+  private:_Jv_ushort max_stack;
+    static void   run (_Jv_InterpMethod *);
+  };
+   class java::lang::Throwable: public::java::lang::Object {
+  public:static::java::lang::Class     class$;
+  };
+   void _Jv_InterpMethod::run (_Jv_InterpMethod * meth) {
+    _Jv_word stack[meth->max_stack];
+    _Jv_word *sp = stack;
+    try   {
+     jfloat value2 = ((jfloat) (--sp)->f);
+     jfloat value1 = ((jfloat) (--sp)->f);
+     if (value1 > value2)       (sp++)->i = (1);
+   }
+    catch (java::lang::Throwable * ex)   {
+   }
+  }