@ -77,18 +77,26 @@
;; Matches values where `ireducing` them will not actually introduce another
;; instruction, since other rules will collapse them with the reduction.
(decl pure multi will_simplify_with_ireduce (Value) Value)
(rule (will_simplify_with_ireduce x@(uextend _ _)) x)
(rule (will_simplify_with_ireduce x@(sextend _ _)) x)
(rule (will_simplify_with_ireduce x@(iconst _ _)) x)
(rule (will_simplify_with_ireduce x@(unary_op _ _ a))
(if-let _ (will_simplify_with_ireduce a))
(decl pure multi will_simplify_with_ireduce_rec (u8 Value) Value)
(rule (will_simplify_with_ireduce_rec _ x@(uextend _ _)) x)
(rule (will_simplify_with_ireduce_rec _ x@(sextend _ _)) x)
(rule (will_simplify_with_ireduce_rec _ x@(iconst _ _)) x)
(rule (will_simplify_with_ireduce_rec depth x@(unary_op _ _ a))
(if-let _ (u8_lt 0 depth))
(if-let _ (reducible_modular_op x))
(if-let _ (will_simplify_with_ireduce_rec (u8_sub depth 1) a))
x)
(rule (will_simplify_with_ireduce x@(binary_op _ _ a b))
(if-let _ (will_simplify_with_ireduce a))
(if-let _ (will_simplify_with_ireduce b))
(rule (will_simplify_with_ireduce_rec depth x@(binary_op _ _ a b))
(if-let _ (u8_lt 0 depth))
(if-let _ (reducible_modular_op x))
(if-let _ (will_simplify_with_ireduce_rec (u8_sub depth 1) a))
(if-let _ (will_simplify_with_ireduce_rec (u8_sub depth 1) b))
x)
(decl pure multi will_simplify_with_ireduce (Value) Value)
(rule (will_simplify_with_ireduce x)
(will_simplify_with_ireduce_rec 2 x))
;; Matches values where the high bits of the input don't affect lower bits of
;; the output, and thus the inputs can be reduced before the operation rather
;; than doing the wide operation then reducing afterwards.