|
| 1 | +--[[ |
| 2 | +SPDX-License-Identifier: ISC |
| 3 | +Copyright (c) 2023-2025, Sergey Bronnikov. |
| 4 | +
|
| 5 | +ARM64: Should not fuse sign-extension into logical operands, |
| 6 | +can fuse rotations though, |
| 7 | +https://github.com/LuaJIT/LuaJIT/issues/1076 |
| 8 | +
|
| 9 | +Wrong code generation for constants in bitwise operations, |
| 10 | +https://github.com/lua/lua/commit/c764ca71a639f5585b5f466bea25dc42b855a4b0 |
| 11 | +
|
| 12 | +Synopsis: bit32.bor (···) |
| 13 | +]] |
| 14 | + |
| 15 | +local luzer = require("luzer") |
| 16 | +local test_lib = require("lib") |
| 17 | + |
| 18 | +local bor |
| 19 | +if test_lib.version() == "LuaJIT" then |
| 20 | + local bitop = require("bit") |
| 21 | + bor = bitop.bor |
| 22 | +else |
| 23 | + bor = test_lib.bitwise_op("|") |
| 24 | +end |
| 25 | + |
| 26 | +local function TestOneInput(buf) |
| 27 | + local fdp = luzer.FuzzedDataProvider(buf) |
| 28 | + local x = test_lib.random_number(fdp) |
| 29 | + local y = test_lib.random_number(fdp) |
| 30 | + local z = test_lib.random_number(fdp) |
| 31 | + bor(x, y) |
| 32 | + |
| 33 | + assert(bor(x, y) == bor(y, x), "x | y ~= y | x") |
| 34 | + assert(bor(x, bor(y, z)) == bor(bor(x, y), z), |
| 35 | + "x | (y | z) ~= (x | y) | z") |
| 36 | + |
| 37 | + -- FIXME |
| 38 | + -- assert(bor(x, 0) == x, "x | 0 ~= x") |
| 39 | + -- assert(bor(x, 0xffff) == 0xffff, "x | 0xFFFF ~= 0xFFFF") |
| 40 | + -- assert(bor(x, x) == x, "x | x ~= x") |
| 41 | +end |
| 42 | + |
| 43 | +local args = { |
| 44 | + max_len = 4096, |
| 45 | + max_total_time = 10, |
| 46 | + artifact_prefix = "bitop_bor_", |
| 47 | +} |
| 48 | +luzer.Fuzz(TestOneInput, nil, args) |
0 commit comments