Implemented b{and,or,xor}_not bitops for ty_int_ref_scalar_64 type. (#5604)

* Implemented `b{and,or,xor}_not` bitops for ty_int_ref_scalar_64 type.

* Added tests.
This commit is contained in:
Jun Ryung Ju
2023-02-02 14:57:18 +09:00
committed by GitHub
parent ac4d28f4dd
commit 9cd4146939
2 changed files with 56 additions and 1 deletions

View File

@@ -1099,9 +1099,33 @@
;; while x86 does ;; while x86 does
;; ;;
;; pandn(x, y) = and(not(x), y) ;; 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)) (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` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; Rules for `iabs` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(rule (lower (has_type $I8X16 (iabs x))) (rule (lower (has_type $I8X16 (iabs x)))

View File

@@ -35,3 +35,34 @@ block0(v0: i64):
} }
; run: %bnot_i64(0) == -1 ; run: %bnot_i64(0) == -1
; run: %bnot_i64(1) == -2 ; 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