Files
wasmtime/cranelift/filetests/filetests/runtests/bitops.clif
Afonso Bordado 9e1ff9726c egraphs: Add bmask bit pattern optimization rule (#6196)
* egraphs: Add a bmask bit pattern optimization

* egraphs: Add more `ineg` rules

* egraphs: Add sshr rule

* egraphs: Simplify bmask rule

* egraphs: Add comutative version of bmask rule

* egraphs: Add more testcases

* egraphs: Cleanup rule comments

* egraphs: Add more `ineg` optimizations
2023-04-14 18:50:48 +00:00

85 lines
2.1 KiB
Plaintext

test run
set opt_level=none
target aarch64
target s390x
target riscv64
target s390x has_mie2
set opt_level=speed
target aarch64
target s390x
target riscv64
target s390x has_mie2
; target x86_64 TODO: Not yet implemented on x86_64
function %bnot_band() -> i8 {
block0:
v1 = iconst.i8 0
v2 = iconst.i8 1
v3 = bnot v1
v4 = band v3, v2
return v4
}
; run
function %bitselect_i8(i8, i8, i8) -> i8 {
block0(v0: i8, v1: i8, v2: i8):
v3 = bitselect v0, v1, v2
return v3
}
; run: %bitselect_i8(0, 0, 0xFF) == 0xFF
; run: %bitselect_i8(0x55, 0, 0xFF) == 0xAA
; run: %bitselect_i8(0xF0, 32, 13) == 45
; run: %bitselect_i8(0xFF, 0xFF, 0) == 0xFF
function %bitselect_i16(i16, i16, i16) -> i16 {
block0(v0: i16, v1: i16, v2: i16):
v3 = bitselect v0, v1, v2
return v3
}
; run: %bitselect_i16(0, 0, 0xFFFF) == 0xFFFF
; run: %bitselect_i16(0x5555, 0, 0xFFFF) == 0xAAAA
; run: %bitselect_i16(0xFFFF, 0xFFFF, 0) == 0xFFFF
function %bitselect_i32(i32, i32, i32) -> i32 {
block0(v0: i32, v1: i32, v2: i32):
v3 = bitselect v0, v1, v2
return v3
}
; run: %bitselect_i32(0, 0, 0xFFFFFFFF) == 0xFFFFFFFF
; run: %bitselect_i32(0x55555555, 0, 0xFFFFFFFF) == 0xAAAAAAAA
; run: %bitselect_i32(0xFFFFFFFF, 0xFFFFFFFF, 0) == 0xFFFFFFFF
function %bitselect_i64(i64, i64, i64) -> i64 {
block0(v0: i64, v1: i64, v2: i64):
v3 = bitselect v0, v1, v2
return v3
}
; run: %bitselect_i64(0, 0, 0xFFFFFFFFFFFFFFFF) == 0xFFFFFFFFFFFFFFFF
; run: %bitselect_i64(0x5555555555555555, 0, 0xFFFFFFFFFFFFFFFF) == 0xAAAAAAAAAAAAAAAA
; run: %bitselect_i64(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF, 0) == 0xFFFFFFFFFFFFFFFF
;; We have a optimization rule in the midend that turns this into a bmask
;; It's easier to have a runtest to ensure that it is correct than to inspect the output.
function %bitops_bmask(i16) -> i16 {
block0(v0: i16):
v1 = bnot v0
v2 = iconst.i16 1
v3 = iadd.i16 v1, v2
v4 = bor.i16 v0, v3
v5 = iconst.i16 15
v6 = ushr.i16 v4, v5
v7 = iconst.i16 1
v8 = isub.i16 v6, v7
v9 = bnot.i16 v8
return v9
}
; run: %bitops_bmask(0) == 0
; run: %bitops_bmask(1) == -1
; run: %bitops_bmask(0xFFFF) == -1
; run: %bitops_bmask(0x8000) == -1