xref: /PHP-8.4/ext/opcache/tests/jit/mul_004.phpt (revision c16ad918)
1--TEST--
2JIT MUL: 004 Overflow check for optmizing MUL to SHIFT
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7;opcache.jit_debug=257
8--EXTENSIONS--
9opcache
10--SKIPIF--
11<?php
12if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
13?>
14--FILE--
15<?php
16
17function mul2_8(int $a) {
18  $res = $a * 8;  // shift cnt: 3
19  var_dump($res);
20}
21
22function mul1_16(int $a) {
23  $res = 16 * $a; // shift cnt: 4
24  var_dump($res);
25}
26
27function mul2_big_int32(int $a) {
28  $res = $a * 0x10000000; // shift cnt: 29
29  var_dump($res);
30}
31
32function mul2_big_int64(int $a) {
33  $res = $a * 0x100000000; // shift cnt: 32
34  var_dump($res);
35}
36
37function mul2(int $a) {
38  $res = $a * 2; // $a + $a
39  var_dump($res);
40}
41
42mul2_8(3);
43mul2_8(-11);
44mul2_8(0x7fffffffffffffff);
45mul1_16(3);
46mul1_16(-13);
47mul1_16(0x7fffffffffffffff);
48mul2_big_int32(3);
49mul2_big_int32(-3);
50mul2_big_int32(0x10000000000);
51mul2_big_int64(3);
52mul2_big_int64(-3);
53mul2_big_int64(0x100000000);
54mul2(10);
55mul2(0x7fffffffffffffff);
56?>
57--EXPECT--
58int(24)
59int(-88)
60float(7.378697629483821E+19)
61int(48)
62int(-208)
63float(1.4757395258967641E+20)
64int(805306368)
65int(-805306368)
66float(2.9514790517935283E+20)
67int(12884901888)
68int(-12884901888)
69float(1.8446744073709552E+19)
70int(20)
71float(1.8446744073709552E+19)
72