xref: /PHP-8.1/ext/opcache/tests/jit/add_007.phpt (revision 3e164dee)
1--TEST--
2JIT ADD: 007 Addition with immediate values
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.file_update_protection=0
7opcache.jit_buffer_size=1M
8opcache.protect_memory=1
9--EXTENSIONS--
10opcache
11--SKIPIF--
12<?php
13if (PHP_INT_SIZE != 8) die("skip: 64-bit only"); ?>
14--FILE--
15<?php
16function foo($a) {
17    $b = 0;
18    $c = 31;
19    $d = 0xfff;
20    $e = 0x1000;
21    $f = 0xfff000;
22    $g = 0xff001;          // Cannot be encoded into imm12 field
23    $h = 0x1000000;        // Cannot be encoded into imm12 field
24    $i = 0xf12345678;      // Cannot be encoded into imm12 field
25    $j = -31;              // Cannot be encoded into imm12 field
26
27    $a = $a + $b;
28    $a = $a + $c;
29    $a = $a + $d;
30    $a = $a + $e;
31    $a = $a + $f;
32    $a = $a + $g;
33    $a = $a + $h;
34    $a = $a + $i;
35    $a = $a + $j;
36    var_dump($a);
37}
38
39function bar($a) {
40    $b = 0;
41    $c = 31;
42    $d = 0xfff;
43    $e = 0x1000;
44    $f = 0xfff000;
45    $g = 0xff001;          // Cannot be encoded into imm12 field
46    $h = 0x1000000;        // Cannot be encoded into imm12 field
47    $i = 0xf12345678;      // Cannot be encoded into imm12 field
48    $j = -31;              // Cannot be encoded into imm12 field
49
50    $a = $a - $b;
51    $a = $a - $c;
52    $a = $a - $d;
53    $a = $a - $e;
54    $a = $a - $f;
55    $a = $a - $g;
56    $a = $a - $h;
57    $a = $a - $i;
58    $a = $a - $j;
59    var_dump($a);
60}
61
62foo(42);
63bar(0x1f12345678);
64?>
65--EXPECT--
66int(64764532386)
67int(68684873728)
68