ISLE: simplify select/bitselect when both choices are the same (#6141)
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
;; `select`/`bitselect`-related rewrites
|
;; `select`/`bitselect`-related rewrites
|
||||||
|
|
||||||
|
;; remove select when both choices are the same
|
||||||
|
(rule (simplify (select ty _ x x)) x)
|
||||||
|
(rule (simplify (bitselect ty _ x x)) x)
|
||||||
|
|
||||||
;; Transform select-of-icmp into {u,s}{min,max} instructions where possible.
|
;; Transform select-of-icmp into {u,s}{min,max} instructions where possible.
|
||||||
(rule (simplify (select ty (sgt _ x y) x y)) (smax ty x y))
|
(rule (simplify (select ty (sgt _ x y) x y)) (smax ty x y))
|
||||||
(rule (simplify (select ty (sge _ x y) x y)) (smax ty x y))
|
(rule (simplify (select ty (sge _ x y) x y)) (smax ty x y))
|
||||||
|
|||||||
@@ -5,6 +5,20 @@ target aarch64
|
|||||||
target s390x
|
target s390x
|
||||||
target riscv64
|
target riscv64
|
||||||
|
|
||||||
|
function %select_self(i8, i32) -> i32 {
|
||||||
|
block0(v0: i8, v1: i32):
|
||||||
|
v2 = select v0, v1, v1
|
||||||
|
return v2
|
||||||
|
; check: return v1
|
||||||
|
}
|
||||||
|
|
||||||
|
function %bitselect_self(i32, i32) -> i32 {
|
||||||
|
block0(v0: i32, v1: i32):
|
||||||
|
v2 = bitselect v0, v1, v1
|
||||||
|
return v2
|
||||||
|
; check: return v1
|
||||||
|
}
|
||||||
|
|
||||||
function %select_sgt_to_smax(i32, i32) -> i32 {
|
function %select_sgt_to_smax(i32, i32) -> i32 {
|
||||||
block0(v0: i32, v1: i32):
|
block0(v0: i32, v1: i32):
|
||||||
v2 = icmp sgt v0, v1
|
v2 = icmp sgt v0, v1
|
||||||
|
|||||||
Reference in New Issue
Block a user