xref: /PHP-8.4/ext/opcache/tests/jit/cmp_005.phpt (revision c16ad918)
1--TEST--
2JIT CMP: 005 Comparisons 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
25    var_dump($a > $b ? 1 : 0);
26    var_dump($a > $c ? 1 : 0);
27    var_dump($a > $d ? 1 : 0);
28    var_dump($a > $e ? 1 : 0);
29    var_dump($a > $f ? 1 : 0);
30    var_dump($a > $g ? 1 : 0);
31    var_dump($a > $h ? 1 : 0);
32    var_dump($a > $i ? 1 : 0);
33}
34
35function bar($a) {
36    $b = 0;
37    $c = -31;
38    $d = -4095;            // negation of 0xfff
39    $e = -4096;            // negation of 0x1000
40    $f = -16773120;        // negation of 0xfff000
41    $g = -1044481;         // negation of 0xff001
42    $h = -16777216;        // negation of 0x1000000
43    $i = -64729929336;     // negation of 0xf12345678
44
45    var_dump($a > $b ? 1 : 0);
46    var_dump($a > $c ? 1 : 0);
47    var_dump($a > $d ? 1 : 0);
48    var_dump($a > $e ? 1 : 0);
49    var_dump($a > $f ? 1 : 0);
50    var_dump($a > $g ? 1 : 0);
51    var_dump($a > $h ? 1 : 0);
52    var_dump($a > $i ? 1 : 0);
53}
54
55foo(42);
56bar(42);
57?>
58--EXPECT--
59int(1)
60int(1)
61int(0)
62int(0)
63int(0)
64int(0)
65int(0)
66int(0)
67int(1)
68int(1)
69int(1)
70int(1)
71int(1)
72int(1)
73int(1)
74int(1)
75