mul_004.phpt 1.3 KB

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