cranelift: Remove redundant branch and select instructions (#5097)
As discussed in the 2022/10/19 meeting, this PR removes many of the branch and select instructions that used iflags, in favor if using brz/brnz and select in their place. Additionally, it reworks selectif_spectre_guard to take an i8 input instead of an iflags input. For reference, the removed instructions are: br_icmp, brif, brff, trueif, trueff, and selectif.
This commit is contained in:
@@ -3726,15 +3726,15 @@
|
||||
(put_in_reg val_true) (put_in_reg val_false)))
|
||||
|
||||
|
||||
;;;; Rules for `selectif_spectre_guard` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; Rules for `select_spectre_guard` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; We do not support the `iflags` mechanism on our platform. However, common
|
||||
;; code will unconditionally emit certain patterns using `iflags` which we
|
||||
;; need to handle somehow. Note that only those specific patterns are
|
||||
;; recognized by the code below, other uses will fail to lower.
|
||||
|
||||
(rule (lower (has_type ty (selectif_spectre_guard int_cc
|
||||
(ifcmp x y) val_true val_false)))
|
||||
(rule (lower (has_type ty (select_spectre_guard
|
||||
(icmp int_cc x y) val_true val_false)))
|
||||
(select_bool_reg ty (icmp_val $false int_cc x y)
|
||||
(put_in_reg val_true) (put_in_reg val_false)))
|
||||
|
||||
@@ -3801,17 +3801,6 @@
|
||||
(vec_element targets 1))))
|
||||
|
||||
|
||||
;;;; Rules for `brif` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
;; Similarly to `selectif_spectre_guard`, we only recognize specific patterns
|
||||
;; generated by common code here. Others will fail to lower.
|
||||
|
||||
(rule (lower_branch (brif int_cc (ifcmp x y) _ _) targets)
|
||||
(side_effect (cond_br_bool (icmp_val $false int_cc x y)
|
||||
(vec_element targets 0)
|
||||
(vec_element targets 1))))
|
||||
|
||||
|
||||
;;;; Rules for `trap` ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(rule (lower (trap trap_code))
|
||||
|
||||
Reference in New Issue
Block a user