Subversion Repositories

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

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

Rev Author Line No. Line
252 holmgren 1
From: Henrik Grubbström <grubba@grubba.org>
2
Date: Thu, 29 Sep 2016 17:25:06 +0200
3
Subject: [PATCH] Compiler [optimizer]: Disabled some broken peep rules.
4
Bug-Debian: https://bugs.debian.org/836673
5
Forwarded: yes
6
Origin: http://pike-librarian.lysator.liu.se/index.xml?checkins=e0fcf06129c03fb51d6da6b13200232a15df7e0d
7
 
8
These peep hole optimizer rules weren't protected against
9
negation overflow.
10
 
11
Disabled since INT32_NEG_OVERFLOW() doesn't exist in Pike 7.8.
12
 
13
Cf Pike 7.9.5 and later commit c63deca838788875b37d48a4faa044b5d6cafa0b.
14
 
15
Thanks to Magnus Holmgren for the report.
16
 
17
Potential fix for [LysLysKOM 21868180] (infinite optimizer loop).
18
---
19
 src/peep.in | 8 ++++----
20
 1 file changed, 4 insertions(+), 4 deletions(-)
21
 
22
diff --git a/src/peep.in b/src/peep.in
23
index f32f7cd..9279d77 100644
24
--- a/src/peep.in
25
+++ b/src/peep.in
26
@@ -36,8 +36,8 @@ CONST1 NEGATE : CONST_1
27
 CONST_1 NEGATE : CONST1
28
 NUMBER NEGATE : NEG_NUMBER($1a)
29
 NEG_NUMBER NEGATE : NUMBER ($1a)
30
-NUMBER [(-$1a) > 0] : NEG_NUMBER (-$1a)
31
-NEG_NUMBER [(-$1a) >= 0] : NUMBER (-$1a)
32
+// NUMBER [(-$1a) > 0] : NEG_NUMBER (-$1a)
33
+// NEG_NUMBER [(-$1a) >= 0] : NUMBER (-$1a)
34
 NEGATE NEGATE :
35
 COMPL COMPL :
36
 NEGATE CONST_1 ADD_INTS : COMPL
37
@@ -238,8 +238,8 @@ CONST_1 INDEX: NEG_INT_INDEX (1)
38
 CONST1 INDEX: POS_INT_INDEX (1)
39
 NUMBER INDEX: POS_INT_INDEX ($1a)
40
 NEG_NUMBER INDEX: NEG_INT_INDEX ($1a)
41
-POS_INT_INDEX [$1a < 0]: NEG_INT_INDEX (-$1a)
42
-NEG_INT_INDEX [-$1a >= 0]: POS_INT_INDEX (-$1a)
43
+// POS_INT_INDEX [$1a < 0]: NEG_INT_INDEX (-$1a)
44
+// NEG_INT_INDEX [-$1a >= 0]: POS_INT_INDEX (-$1a)
45
 
46
 BRANCH_WHEN_ZERO BRANCH LABEL ($1a): BRANCH_WHEN_NON_ZERO($2a) LABEL($1a)
47
 BRANCH_WHEN_NON_ZERO BRANCH LABEL ($1a): BRANCH_WHEN_ZERO($2a) LABEL($1a)
255 holmgren 48
--- a/src/peep_engine.c   2014-05-01 08:28:45.000000000 +0200
49
+++ b/src/peep_engine.c   2016-09-29 23:43:05.238716680 +0200
50
@@ -4586,15 +4586,6 @@
51
     }
52
     break;
53
 
54
-  case F_NEG_INT_INDEX:
55
-    /* NEG_INT_INDEX [-$1a >= 0]: POS_INT_INDEX (-$1a) */
56
-    if(-argument(0) >= 0)
57
-    {
58
-      do_optimization(1, 1, 2, F_POS_INT_INDEX, -argument(0), 0);
59
-      return 1;
60
-    }
61
-    break;
62
-
63
   case F_NEG_NUMBER:
64
     /* NEG_NUMBER(1) : CONST_1 */
65
     if((1)==argument(0))
66
@@ -4602,12 +4593,6 @@
67
       do_optimization(1, 1, 1, F_CONST_1, 0);
68
       return 1;
69
     }
70
-    /* NEG_NUMBER [(-$1a) >= 0] : NUMBER (-$1a) */
71
-    if((-argument(0)) >= 0)
72
-    {
73
-      do_optimization(1, 1, 2, F_NUMBER, -argument(0), 0);
74
-      return 1;
75
-    }
76
     break;
77
 
78
   case F_NOP:
79
@@ -4652,12 +4637,6 @@
80
       do_optimization(1, 1, 1, F_BIGNUM, 0);
81
       return 1;
82
     }
83
-    /* NUMBER [(-$1a) > 0] : NEG_NUMBER (-$1a) */
84
-    if((-argument(0)) > 0)
85
-    {
86
-      do_optimization(1, 1, 2, F_NEG_NUMBER, -argument(0), 0);
87
-      return 1;
88
-    }
89
     break;
90
 
91
   case F_POP_N_ELEMS:
92
@@ -4665,15 +4644,6 @@
93
       return 1;
94
     break;
95
 
96
-  case F_POS_INT_INDEX:
97
-    /* POS_INT_INDEX [$1a < 0]: NEG_INT_INDEX (-$1a) */
98
-    if(argument(0) < 0)
99
-    {
100
-      do_optimization(1, 1, 2, F_NEG_INT_INDEX, -argument(0), 0);
101
-      return 1;
102
-    }
103
-    break;
104
-
105
   }
106
   return 0;
107
 }