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