egraph opt rules: do (icmp cc x x) == {0,1} only for integer types. (#5438)

We could do these for vectors too, in theory, but for now let's fix the
bug by applying the equivalence only for integer types.

Fixes #5437.
This commit is contained in:
Chris Fallin
2022-12-14 11:50:42 -08:00
committed by GitHub
parent 2e0bc7dab6
commit 8383e4b6bd
2 changed files with 51 additions and 10 deletions

View File

@@ -211,32 +211,32 @@
;; `x == x` is always true for integers; `x != x` is false. Strict
;; inequalities are false, and loose inequalities are true.
(rule (simplify
(icmp ty (IntCC.Equal) x x))
(icmp (ty_int ty) (IntCC.Equal) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.NotEqual) x x))
(icmp (ty_int ty) (IntCC.NotEqual) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.UnsignedGreaterThan) x x))
(icmp (ty_int ty) (IntCC.UnsignedGreaterThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.UnsignedGreaterThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.UnsignedGreaterThanOrEqual) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.SignedGreaterThan) x x))
(icmp (ty_int ty) (IntCC.SignedGreaterThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.SignedGreaterThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.SignedGreaterThanOrEqual) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.UnsignedLessThan) x x))
(icmp (ty_int ty) (IntCC.UnsignedLessThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.UnsignedLessThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.UnsignedLessThanOrEqual) x x))
(iconst ty (imm64 1)))
(rule (simplify
(icmp ty (IntCC.SignedLessThan) x x))
(icmp (ty_int ty) (IntCC.SignedLessThan) x x))
(iconst ty (imm64 0)))
(rule (simplify
(icmp ty (IntCC.SignedLessThanOrEqual) x x))
(icmp (ty_int ty) (IntCC.SignedLessThanOrEqual) x x))
(iconst ty (imm64 1)))