From 42528d82b8985e0c9d8b0530944e58d885ff7828 Mon Sep 17 00:00:00 2001 From: Karl Meakin Date: Wed, 12 Apr 2023 20:04:30 +0100 Subject: [PATCH] Add `multi_lane` precondition to `bitselect` => `{u,s}{min,max}` rewrite (#6201) --- cranelift/codegen/src/opts/selects.isle | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/cranelift/codegen/src/opts/selects.isle b/cranelift/codegen/src/opts/selects.isle index 1fcc6c8d64..ba682fcc31 100644 --- a/cranelift/codegen/src/opts/selects.isle +++ b/cranelift/codegen/src/opts/selects.isle @@ -25,24 +25,24 @@ (rule (simplify (select ty (uge _ x y) y x)) (umin ty x y)) ;; Transform bitselect-of-icmp into {u,s}{min,max} instructions where possible. -(rule (simplify (bitselect ty (sgt _ x y) x y)) (smax ty x y)) -(rule (simplify (bitselect ty (sge _ x y) x y)) (smax ty x y)) -(rule (simplify (bitselect ty (ugt _ x y) x y)) (umax ty x y)) -(rule (simplify (bitselect ty (uge _ x y) x y)) (umax ty x y)) -(rule (simplify (bitselect ty (slt _ x y) x y)) (smin ty x y)) -(rule (simplify (bitselect ty (sle _ x y) x y)) (smin ty x y)) -(rule (simplify (bitselect ty (ult _ x y) x y)) (umin ty x y)) -(rule (simplify (bitselect ty (ule _ x y) x y)) (umin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (sgt _ x y) x y)) (smax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (sge _ x y) x y)) (smax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (ugt _ x y) x y)) (umax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (uge _ x y) x y)) (umax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (slt _ x y) x y)) (smin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (sle _ x y) x y)) (smin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (ult _ x y) x y)) (umin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (ule _ x y) x y)) (umin ty x y)) ;; These are the same rules as above, but when the operands for select are swapped -(rule (simplify (bitselect ty (slt _ x y) y x)) (smax ty x y)) -(rule (simplify (bitselect ty (sle _ x y) y x)) (smax ty x y)) -(rule (simplify (bitselect ty (ult _ x y) y x)) (umax ty x y)) -(rule (simplify (bitselect ty (ule _ x y) y x)) (umax ty x y)) -(rule (simplify (bitselect ty (sgt _ x y) y x)) (smin ty x y)) -(rule (simplify (bitselect ty (sge _ x y) y x)) (smin ty x y)) -(rule (simplify (bitselect ty (ugt _ x y) y x)) (umin ty x y)) -(rule (simplify (bitselect ty (uge _ x y) y x)) (umin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (slt _ x y) y x)) (smax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (sle _ x y) y x)) (smax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (ult _ x y) y x)) (umax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (ule _ x y) y x)) (umax ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (sgt _ x y) y x)) (smin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (sge _ x y) y x)) (smin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (ugt _ x y) y x)) (umin ty x y)) +(rule (simplify (bitselect ty @ (multi_lane _ _) (uge _ x y) y x)) (umin ty x y)) ;; For floats convert fcmp lt into pseudo_min and gt into pseudo_max ;;