Stream: cranelift

Topic: ✔ ISLE or patterns


view this post on Zulip kmeakin (Mar 23 2023 at 18:56):

Does ISLE support or patterns?
I'd like to replace

;; eq(x, y) && ne(x, y) == ne(x, y) && eq(x, y) == false.
(rule (simplify (band ty (eq ty x y) (ne ty x y))) (subsume (iconst ty (imm64 0))))
(rule (simplify (band ty (ne ty x y) (eq ty x y))) (subsume (iconst ty (imm64 0))))

;; eq(x, y) && ult(x, y) == ult(x, y) && eq(x, y) == false.
(rule (simplify (band ty (eq ty x y) (ult ty x y))) (subsume (iconst ty (imm64 0))))
(rule (simplify (band ty (ult ty x y) (eq ty x y))) (subsume (iconst ty (imm64 0))))

;; eq(x, y) && ugt(x, y) == ugt(x, y) && eq(x, y) == false.
(rule (simplify (band ty (eq ty x y) (ugt ty x y))) (subsume (iconst ty (imm64 0))))
(rule (simplify (band ty (ugt ty x y) (eq ty x y))) (subsume (iconst ty (imm64 0))))

;; eq(x, y) && slt(x, y) == slt(x, y) && eq(x, y) == false.
(rule (simplify (band ty (eq ty x y) (slt ty x y))) (subsume (iconst ty (imm64 0))))
(rule (simplify (band ty (slt ty x y) (eq ty x y))) (subsume (iconst ty (imm64 0))))

with something like

(rule (simplify (band ty (eq ty x y) (icmp_inequality ty x y))) (subsume (iconst ty (imm64 0))))
(rule (simplify (band ty (icmp_inequality ty x y) (eq ty x y))) (subsume (iconst ty (imm64 0))))

view this post on Zulip Chris Fallin (Mar 23 2023 at 18:57):

Currently, no; @Trevor Elliott has talked about wanting to add them though

view this post on Zulip kmeakin (Mar 23 2023 at 18:58):

Where icmp_inequality is

(decl icmp_inequality (Type Value Value) Value)
(extractor (icmp_inequality ty x y)
  (or
    (icmp ty (IntCC.NotEqual) x y)
    (icmp ty (IntCC.NotEqual) y x)
    (icmp ty (IntCC.UnsignedLessThan) x y)
    (icmp ty (IntCC.UnsignedLessThan) y x)
    (icmp ty (IntCC.UnsignedGreaterThan) x y)
    (icmp ty (IntCC.UnsignedGreaterThan) y x)
    (icmp ty (IntCC.SignedLessThan) x y)
    (icmp ty (IntCC.SignedLessThan) y x)
    (icmp ty (IntCC.SignedGreaterThan) x y)
    (icmp ty (IntCC.SignedGreaterThan) y x)))

view this post on Zulip Chris Fallin (Mar 23 2023 at 19:00):

if you're up for a deep dive into islec, we could talk about how they might be implemented (basically: duplicate the rules in a desugaring pass) though

view this post on Zulip Chris Fallin (Mar 23 2023 at 19:00):

basically we don't have much developer time to hack on ISLE proper, so stuff has to be built by those who want it :-)

view this post on Zulip Notification Bot (Mar 23 2023 at 22:46):

kmeakin has marked this topic as resolved.


Last updated: Nov 22 2024 at 16:03 UTC