xref: /PHP-8.1/ext/opcache/tests/opt/gh11170.phpt (revision fbf5216c)
1--TEST--
2GH-11170 (Too wide OR and AND range inferred)
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7opcache.opt_debug_level=0x400000
8opcache.preload=
9--EXTENSIONS--
10opcache
11--FILE--
12<?php
13function test_or() {
14    if (rand() % 10) {
15        $a = -27;
16        $b = -20;
17    } else {
18        $a = -7;
19        $b = -10;
20    }
21
22    return $a | $b;
23}
24
25function test_and() {
26    if (rand() % 10) {
27        $a = -12;
28        $b = -27;
29    } else {
30        $a = -9;
31        $b = -25;
32    }
33
34    return $a & $b;
35}
36
37test_or();
38test_and();
39?>
40--EXPECTF--
41$_main:
42     ; (lines=5, args=0, vars=0, tmps=2, ssa_vars=0, no_loops)
43     ; (after dfa pass)
44     ; %s
45     ; return  [long] RANGE[1..1]
46BB0:
47     ; start exit lines=[0-4]
48     ; level=0
490000 INIT_FCALL 0 %d string("test_or")
500001 DO_UCALL
510002 INIT_FCALL 0 %d string("test_and")
520003 DO_UCALL
530004 RETURN int(1)
54
55test_or:
56     ; (lines=11, args=0, vars=2, tmps=7, ssa_vars=11, no_loops)
57     ; (after dfa pass)
58     ; %s
59     ; return  [long] RANGE[-20..-1]
60     ; #0.CV0($a) NOVAL [undef]
61     ; #1.CV1($b) NOVAL [undef]
62BB0:
63     ; start lines=[0-3]
64     ; to=(BB2, BB1)
65     ; level=0
66     ; children=(BB1, BB2, BB3)
670000 INIT_FCALL 0 %d string("rand")
680001 #2.V2 [long] = DO_ICALL
690002 #3.T3 [long] RANGE[MIN..MAX] = MOD #2.V2 [long] int(10)
700003 JMPZ #3.T3 [long] RANGE[MIN..MAX] BB2
71
72BB1:
73     ; follow lines=[4-6]
74     ; from=(BB0)
75     ; to=(BB3)
76     ; idom=BB0
77     ; level=1
780004 #4.CV0($a) [long] RANGE[-27..-27] = QM_ASSIGN int(-27)
790005 #5.CV1($b) [long] RANGE[-20..-20] = QM_ASSIGN int(-20)
800006 JMP BB3
81
82BB2:
83     ; target lines=[7-8]
84     ; from=(BB0)
85     ; to=(BB3)
86     ; idom=BB0
87     ; level=1
880007 #6.CV0($a) [long] RANGE[-7..-7] = QM_ASSIGN int(-7)
890008 #7.CV1($b) [long] RANGE[-10..-10] = QM_ASSIGN int(-10)
90
91BB3:
92     ; follow target exit lines=[9-10]
93     ; from=(BB1, BB2)
94     ; idom=BB0
95     ; level=1
96     #8.CV0($a) [long] RANGE[-27..-7] = Phi(#4.CV0($a) [long] RANGE[-27..-27], #6.CV0($a) [long] RANGE[-7..-7])
97     #9.CV1($b) [long] RANGE[-20..-10] = Phi(#5.CV1($b) [long] RANGE[-20..-20], #7.CV1($b) [long] RANGE[-10..-10])
980009 #10.T8 [long] RANGE[-20..-1] = BW_OR #8.CV0($a) [long] RANGE[-27..-7] #9.CV1($b) [long] RANGE[-20..-10]
990010 RETURN #10.T8 [long] RANGE[-20..-1]
100
101test_and:
102     ; (lines=11, args=0, vars=2, tmps=7, ssa_vars=11, no_loops)
103     ; (after dfa pass)
104     ; %s
105     ; return  [long] RANGE[-28..-25]
106     ; #0.CV0($a) NOVAL [undef]
107     ; #1.CV1($b) NOVAL [undef]
108BB0:
109     ; start lines=[0-3]
110     ; to=(BB2, BB1)
111     ; level=0
112     ; children=(BB1, BB2, BB3)
1130000 INIT_FCALL 0 %d string("rand")
1140001 #2.V2 [long] = DO_ICALL
1150002 #3.T3 [long] RANGE[MIN..MAX] = MOD #2.V2 [long] int(10)
1160003 JMPZ #3.T3 [long] RANGE[MIN..MAX] BB2
117
118BB1:
119     ; follow lines=[4-6]
120     ; from=(BB0)
121     ; to=(BB3)
122     ; idom=BB0
123     ; level=1
1240004 #4.CV0($a) [long] RANGE[-12..-12] = QM_ASSIGN int(-12)
1250005 #5.CV1($b) [long] RANGE[-27..-27] = QM_ASSIGN int(-27)
1260006 JMP BB3
127
128BB2:
129     ; target lines=[7-8]
130     ; from=(BB0)
131     ; to=(BB3)
132     ; idom=BB0
133     ; level=1
1340007 #6.CV0($a) [long] RANGE[-9..-9] = QM_ASSIGN int(-9)
1350008 #7.CV1($b) [long] RANGE[-25..-25] = QM_ASSIGN int(-25)
136
137BB3:
138     ; follow target exit lines=[9-10]
139     ; from=(BB1, BB2)
140     ; idom=BB0
141     ; level=1
142     #8.CV0($a) [long] RANGE[-12..-9] = Phi(#4.CV0($a) [long] RANGE[-12..-12], #6.CV0($a) [long] RANGE[-9..-9])
143     #9.CV1($b) [long] RANGE[-27..-25] = Phi(#5.CV1($b) [long] RANGE[-27..-27], #7.CV1($b) [long] RANGE[-25..-25])
1440009 #10.T8 [long] RANGE[-28..-25] = BW_AND #8.CV0($a) [long] RANGE[-12..-9] #9.CV1($b) [long] RANGE[-27..-25]
1450010 RETURN #10.T8 [long] RANGE[-28..-25]
146