diff --git a/cranelift/codegen/src/isa/x64/lower.isle b/cranelift/codegen/src/isa/x64/lower.isle index fc031add54..9b3553f4ed 100644 --- a/cranelift/codegen/src/isa/x64/lower.isle +++ b/cranelift/codegen/src/isa/x64/lower.isle @@ -1099,9 +1099,33 @@ ;; while x86 does ;; ;; pandn(x, y) = and(not(x), y) -(rule (lower (has_type ty (band_not x y))) +(rule 0 (lower (has_type ty (band_not x y))) (sse_and_not ty y x)) + +(rule 1 (lower (has_type ty (band_not x y))) + (if (ty_int_ref_scalar_64 ty)) + (x64_and ty + x + (x64_not ty y))) + + +;;;; Rules for `bxor_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule 0 (lower (has_type ty (bxor_not x y))) + (if (ty_int_ref_scalar_64 ty)) + (x64_xor ty + x + (x64_not ty y))) + +;;;; Rules for `bor_not` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(rule 0 (lower (has_type ty (bor_not x y))) + (if (ty_int_ref_scalar_64 ty)) + (x64_or ty + x + (x64_not ty y))) + ;;;; Rules for `iabs` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (rule (lower (has_type $I8X16 (iabs x))) diff --git a/cranelift/filetests/filetests/runtests/bnot.clif b/cranelift/filetests/filetests/runtests/bnot.clif index a169bcd6bc..c29b525e44 100644 --- a/cranelift/filetests/filetests/runtests/bnot.clif +++ b/cranelift/filetests/filetests/runtests/bnot.clif @@ -35,3 +35,34 @@ block0(v0: i64): } ; run: %bnot_i64(0) == -1 ; run: %bnot_i64(1) == -2 + + +function %band_not(i8, i8) -> i8 { +block0(v0: i8, v1: i8): + v2 = band_not.i8 v0, v1 + return v2 +} + +; run: %band_not(0xFF, 0) == -1 +; run: %band_not(0x55, 0xFF) == 0 +; run: %band_not(0, 0) == 0 + +function %bor_not(i8, i8) -> i8 { +block0(v0: i8, v1: i8): + v2 = bor_not.i8 v0, v1 + return v2 +} + +; run: %bor_not(0xFF, 0) == -1 +; run: %bor_not(0x55, 0xFF) == 85 +; run: %bor_not(0, 0) == -1 + +function %bxor_not(i8, i8) -> i8 { +block0(v0: i8, v1: i8): + v2 = bxor_not.i8 v0, v1 + return v2 +} + +; run: %bxor_not(0xFF, 0) == 0 +; run: %bxor_not(0x55, 0xFF) == 85 +; run: %bxor_not(0, 0) == -1 \ No newline at end of file