ISLE: simplify select/bitselect when both choices are the same (#6141)

This commit is contained in:
Karl Meakin
2023-04-11 23:41:19 +01:00
committed by GitHub
parent b9a58148cf
commit c0166f78f9
2 changed files with 18 additions and 0 deletions

View File

@@ -1,5 +1,9 @@
;; `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.
(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))

View File

@@ -5,6 +5,20 @@ target aarch64
target s390x
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 {
block0(v0: i32, v1: i32):
v2 = icmp sgt v0, v1