Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 252 | Blame | Compare with Previous | Last modification | View Log | RSS feed

From: Henrik Grubbström <grubba@grubba.org>
Date: Thu, 29 Sep 2016 17:25:06 +0200
Subject: [PATCH] Compiler [optimizer]: Disabled some broken peep rules.
Bug-Debian: https://bugs.debian.org/836673
Forwarded: yes
Origin: http://pike-librarian.lysator.liu.se/index.xml?checkins=e0fcf06129c03fb51d6da6b13200232a15df7e0d

These peep hole optimizer rules weren't protected against
negation overflow.

Disabled since INT32_NEG_OVERFLOW() doesn't exist in Pike 7.8.

Cf Pike 7.9.5 and later commit c63deca838788875b37d48a4faa044b5d6cafa0b.

Thanks to Magnus Holmgren for the report.

Potential fix for [LysLysKOM 21868180] (infinite optimizer loop).
---
 src/peep.in | 8 ++++----

 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/peep.in b/src/peep.in
index f32f7cd..9279d77 100644
--- a/src/peep.in
+++ b/src/peep.in
@@ -36,8 +36,8 @@ CONST1 NEGATE : CONST_1
 CONST_1 NEGATE : CONST1
 NUMBER NEGATE : NEG_NUMBER($1a)
 NEG_NUMBER NEGATE : NUMBER ($1a)
-NUMBER [(-$1a) > 0] : NEG_NUMBER (-$1a)
-NEG_NUMBER [(-$1a) >= 0] : NUMBER (-$1a)
+// NUMBER [(-$1a) > 0] : NEG_NUMBER (-$1a)
+// NEG_NUMBER [(-$1a) >= 0] : NUMBER (-$1a)
 NEGATE NEGATE :
 COMPL COMPL :
 NEGATE CONST_1 ADD_INTS : COMPL
@@ -238,8 +238,8 @@ CONST_1 INDEX: NEG_INT_INDEX (1)
 CONST1 INDEX: POS_INT_INDEX (1)
 NUMBER INDEX: POS_INT_INDEX ($1a)
 NEG_NUMBER INDEX: NEG_INT_INDEX ($1a)
-POS_INT_INDEX [$1a < 0]: NEG_INT_INDEX (-$1a)
-NEG_INT_INDEX [-$1a >= 0]: POS_INT_INDEX (-$1a)
+// POS_INT_INDEX [$1a < 0]: NEG_INT_INDEX (-$1a)
+// NEG_INT_INDEX [-$1a >= 0]: POS_INT_INDEX (-$1a)
 
 BRANCH_WHEN_ZERO BRANCH LABEL ($1a): BRANCH_WHEN_NON_ZERO($2a) LABEL($1a)
 BRANCH_WHEN_NON_ZERO BRANCH LABEL ($1a): BRANCH_WHEN_ZERO($2a) LABEL($1a)
--- a/src/peep_engine.c   2014-05-01 08:28:45.000000000 +0200
+++ b/src/peep_engine.c   2016-09-29 23:43:05.238716680 +0200
@@ -4586,15 +4586,6 @@
     }
     break;
 
-  case F_NEG_INT_INDEX:
-    /* NEG_INT_INDEX [-$1a >= 0]: POS_INT_INDEX (-$1a) */
-    if(-argument(0) >= 0)
-    {
-      do_optimization(1, 1, 2, F_POS_INT_INDEX, -argument(0), 0);
-      return 1;
-    }
-    break;
-
   case F_NEG_NUMBER:
     /* NEG_NUMBER(1) : CONST_1 */
     if((1)==argument(0))
@@ -4602,12 +4593,6 @@
       do_optimization(1, 1, 1, F_CONST_1, 0);
       return 1;
     }
-    /* NEG_NUMBER [(-$1a) >= 0] : NUMBER (-$1a) */
-    if((-argument(0)) >= 0)
-    {
-      do_optimization(1, 1, 2, F_NUMBER, -argument(0), 0);
-      return 1;
-    }
     break;
 
   case F_NOP:
@@ -4652,12 +4637,6 @@
       do_optimization(1, 1, 1, F_BIGNUM, 0);
       return 1;
     }
-    /* NUMBER [(-$1a) > 0] : NEG_NUMBER (-$1a) */
-    if((-argument(0)) > 0)
-    {
-      do_optimization(1, 1, 2, F_NEG_NUMBER, -argument(0), 0);
-      return 1;
-    }
     break;
 
   case F_POP_N_ELEMS:
@@ -4665,15 +4644,6 @@
       return 1;
     break;
 
-  case F_POS_INT_INDEX:
-    /* POS_INT_INDEX [$1a < 0]: NEG_INT_INDEX (-$1a) */
-    if(argument(0) < 0)
-    {
-      do_optimization(1, 1, 2, F_NEG_INT_INDEX, -argument(0), 0);
-      return 1;
-    }
-    break;
-
   }
   return 0;
 }