xref: /php-src/ext/opcache/tests/jit/bug81225_2.phpt (revision c16ad918)
1--TEST--
2Bug #81225: Wrong result with pow operator with JIT enabled
3--EXTENSIONS--
4opcache
5--INI--
6opcache.enable=1
7opcache.enable_cli=1
8opcache.jit=function
9--SKIPIF--
10<?php if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
11--FILE--
12<?php
13function add_with_positive(int $a) {
14    $a = $a % 10;
15    $b = $a + 1;
16    $c = $a + 100;
17    $d = $a + 2147483647;          // 0x7fff,ffff
18    $e = $a + 2147483648;          // 0x8000,0000     cannot encoded as imm field of lea r1, [r2 + imm]
19    $f = $a + 78187493394;         // 0x12,1234,5678  cannot encoded as imm field of lea r1, [r2 + imm]
20    var_dump($b, $c, $d, $e, $f);
21}
22
23function add_with_negative(int $a) {
24    $a = $a % 10;
25    $b = $a + (-1);
26    $c = $a + (-100);
27    $d = $a + (-2147483648);       // 0xFFFF,FFFF,8000,0000
28    $e = $a + (-2147483649);       // 0xFFFF,FFFF,7FFF,FFFF  cannot encoded as imm field of lea r1, [r2 + imm]
29    $f = $a + (-261458978401740);  // 0xFFFF,1234,5678,1234  cannot encoded as imm field of lea r1, [r2 + imm]
30    var_dump($b, $c, $d, $e, $f);
31}
32
33function sub_with_positive(int $a) {
34    $a = $a % 10;
35    $b = $a - 1;
36    $c = $a - 100;
37    $d = $a - 2147483647;          // 0x7fff,ffff
38    $e = $a - 2147483648;          // 0x8000,0000
39    $f = $a - 2147483649;          // 0x8000,0001     cannot encoded as imm field of lea r1, [r2 + imm]
40    $g = $a - 78187493394;         // 0x12,1234,5678  cannot encoded as imm field of lea r1, [r2 + imm]
41    var_dump($b, $c, $d, $e, $f, $g);
42}
43
44function sub_with_negative(int $a) {
45    $a = $a % 10;
46    $b = $a - (-1);
47    $c = $a - (-100);
48    $d = $a - (-2147483647);       // 0xFFFF,FFFF,8000,0001
49    $e = $a - (-2147483648);       // 0xFFFF,FFFF,8000,0000  cannot encoded as imm field of lea r1, [r2 + imm]
50    $f = $a - (-2147483649);       // 0xFFFF,FFFF,7FFF,FFFF  cannot encoded as imm field of lea r1, [r2 + imm]
51    $g = $a - (-261458978401740);  // 0xFFFF,1234,5678,1234  cannot encoded as imm field of lea r1, [r2 + imm]
52    var_dump($b, $c, $d, $e, $f, $g);
53}
54
55add_with_positive(2);
56add_with_negative(2);
57sub_with_positive(2);
58sub_with_negative(2);
59?>
60--EXPECT--
61int(3)
62int(102)
63int(2147483649)
64int(2147483650)
65int(78187493396)
66int(1)
67int(-98)
68int(-2147483646)
69int(-2147483647)
70int(-261458978401738)
71int(1)
72int(-98)
73int(-2147483645)
74int(-2147483646)
75int(-2147483647)
76int(-78187493392)
77int(3)
78int(102)
79int(2147483649)
80int(2147483650)
81int(2147483651)
82int(261458978401742)
83