Skip to content

Commit af40223

Browse files
committed
[RuleSet] fix Hydra division lowering
1 parent c0d3f5e commit af40223

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

cranelift/codegen/src/opts/hydra.isle

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,6 @@
553553
(simplify (ushr ty (bxor ty x (iconst_u ty c1)) (iconst_u ty c2)))
554554
(bxor ty (ushr ty (iconst_u ty c1) (iconst_u ty c2)) (ushr ty x (iconst_u ty c2)))
555555
)
556-
(rule
557-
(simplify (ushr ty (ushr ty (iconst_u ty c1) x) (iconst_u ty c2)))
558-
(ushr ty (udiv (iconst_u ty c1) (ishl ty (iconst_u ty 1) (iconst_u ty c2))) x)
559-
)
560556
(rule (simplify (band ty (band ty x y) x)) (band ty x y))
561557
(rule (simplify (band ty (band ty y x) x)) (band ty x y))
562558
(rule (simplify (band ty (iconst_u ty 1) (ushr ty (iconst_u ty 1) x))) (ushr ty (iconst_u ty 1) x))
@@ -714,24 +710,20 @@
714710
(rule (simplify (isub ty x (isub ty y z))) (iadd ty x (isub ty z y)))
715711
(rule (simplify (isub ty x x)) (iconst_u ty 0))
716712
(rule (simplify (isub ty x y)) (bxor ty y x))
717-
(rule (simplify (select ty (eq cty (iconst_u ty 1) x) (udiv y x) z)) (select ty (eq cty x (iconst_u ty 1)) y z))
718713
(rule (simplify (select ty (eq cty (iconst_u ty c1) x) (iconst_u ty 0) (isub ty (iconst_u ty c1) x))) (isub ty (iconst_u ty c1) x))
719714
(rule (simplify (select ty (eq cty (iconst_u ty c1) x) (imul ty x y) z)) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
720715
(rule (simplify (select ty (eq cty (iconst_u ty c1) x) (imul ty y x) z)) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
721716
(rule (simplify (select ty (eq cty (iconst_u ty c1) x) (ushr ty y x) z)) (select ty (eq cty (iconst_u ty c1) x) (ushr ty y (iconst_u ty c1)) z))
722-
(rule (simplify (select ty (eq cty x (iconst_u ty 1)) (udiv y x) z)) (select ty (eq cty x (iconst_u ty 1)) y z))
723717
(rule (simplify (select ty (eq cty x (iconst_u ty c1)) (iconst_u ty 0) (isub ty (iconst_u ty c1) x))) (isub ty (iconst_u ty c1) x))
724718
(rule (simplify (select ty (eq cty x (iconst_u ty c1)) (imul ty x y) z)) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
725719
(rule (simplify (select ty (eq cty x (iconst_u ty c1)) (imul ty y x) z)) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
726720
(rule (simplify (select ty (eq cty x (iconst_u ty c1)) (ushr ty y x) z)) (select ty (eq cty (iconst_u ty c1) x) (ushr ty y (iconst_u ty c1)) z))
727721
(rule (simplify (select ty (eq cty x y) (isub ty y x) z)) (select ty (eq cty x y) (iconst_u ty 0) z))
728722
(rule (simplify (select ty (eq cty y x) (isub ty y x) z)) (select ty (eq cty x y) (iconst_u ty 0) z))
729-
(rule (simplify (select ty (ne cty (iconst_u ty 1) x) z (udiv y x))) (select ty (eq cty x (iconst_u ty 1)) y z))
730723
(rule (simplify (select ty (ne cty (iconst_u ty c1) x) (isub ty (iconst_u ty c1) x) (iconst_u ty 0))) (isub ty (iconst_u ty c1) x))
731724
(rule (simplify (select ty (ne cty (iconst_u ty c1) x) z (imul ty x y))) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
732725
(rule (simplify (select ty (ne cty (iconst_u ty c1) x) z (imul ty y x))) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
733726
(rule (simplify (select ty (ne cty (iconst_u ty c1) x) z (ushr ty y x))) (select ty (eq cty (iconst_u ty c1) x) (ushr ty y (iconst_u ty c1)) z))
734-
(rule (simplify (select ty (ne cty x (iconst_u ty 1)) z (udiv y x))) (select ty (eq cty x (iconst_u ty 1)) y z))
735727
(rule (simplify (select ty (ne cty x (iconst_u ty c1)) (isub ty (iconst_u ty c1) x) (iconst_u ty 0))) (isub ty (iconst_u ty c1) x))
736728
(rule (simplify (select ty (ne cty x (iconst_u ty c1)) z (imul ty x y))) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
737729
(rule (simplify (select ty (ne cty x (iconst_u ty c1)) z (imul ty y x))) (select ty (eq cty (iconst_u ty c1) x) (imul ty (iconst_u ty c1) y) z))
@@ -770,10 +762,7 @@
770762
(rule (simplify (slt cty x (select ty (sle cty y x) y x))) (iconst_u ty 0))
771763
(rule (simplify (slt cty x (select ty (slt cty x y) x y))) (iconst_u ty 0))
772764
(rule (simplify (slt cty x (select ty (slt cty x y) y x))) (slt cty x y))
773-
(rule (simplify (udiv x (band ty (ishl ty (iconst_u ty 1) z) y))) (ushr ty x z))
774-
(rule (simplify (udiv x (band ty y (ishl ty (iconst_u ty 1) z)))) (ushr ty x z))
775765
(rule (simplify (ugt cty (iconst_u ty 1) (ishl ty (iconst_u ty 1) x))) (iconst_u ty 0))
776-
(rule (simplify (ugt cty (iconst_u ty c1) (udiv (iconst_u ty c1) x))) (if-let true (u64_is_power_of_two c1)) (ult cty (iconst_u ty 1) x))
777766
(rule (simplify (ugt cty x (select ty (uge cty x y) y x))) (ult cty y x))
778767
(rule (simplify (ugt cty x (select ty (ugt cty y x) x y))) (ult cty y x))
779768
(rule (simplify (ugt cty x (select ty (ule cty y x) y x))) (ult cty y x))
@@ -783,6 +772,7 @@
783772
(rule (simplify (ult cty (select ty (ugt cty y x) x y) x)) (ult cty y x))
784773
(rule (simplify (ult cty (select ty (ule cty y x) y x) x)) (ult cty y x))
785774
(rule (simplify (ult cty (select ty (ult cty x y) x y) x)) (ult cty y x))
786-
(rule (simplify (ult cty (udiv (iconst_u ty c1) x) (iconst_u ty c1))) (if-let true (u64_is_power_of_two c1)) (ult cty (iconst_u ty 1) x))
787775
(rule (simplify (ushr ty (band ty (ishl ty y z) x) z)) (band ty y (ushr ty x z)))
788776
(rule (simplify (ushr ty (band ty x (ishl ty y z)) z)) (band ty y (ushr ty x z)))
777+
(rule (simplify_skeleton (udiv x (band ty (ishl ty (iconst_u ty 1) z) y))) (ushr ty x z))
778+
(rule (simplify_skeleton (udiv x (band ty y (ishl ty (iconst_u ty 1) z)))) (ushr ty x z))

0 commit comments

Comments
 (0)