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