From 65c1f654f24cb9537e1c4484350a5280283b9e15 Mon Sep 17 00:00:00 2001 From: Jamey Sharp Date: Mon, 6 Feb 2023 14:10:29 -0800 Subject: [PATCH] Cranelift: Only build iconst for ints <= 64 bits (#5723) I audited the egraph "algebraic" optimization rules for any which construct an `iconst` on the right-hand side of the rule. In these cases we need to constrain the type passed to `iconst` to be both `fits_in_64` and `ty_int`, because `iconst` is not defined on other types. --- cranelift/codegen/src/opts/algebraic.isle | 25 +++++++++++++---------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/cranelift/codegen/src/opts/algebraic.isle b/cranelift/codegen/src/opts/algebraic.isle index 888dd51bbc..061c61c511 100644 --- a/cranelift/codegen/src/opts/algebraic.isle +++ b/cranelift/codegen/src/opts/algebraic.isle @@ -101,7 +101,7 @@ (subsume x)) ;; x ^ x == 0. -(rule (simplify (bxor (fits_in_64 ty) x x)) +(rule (simplify (bxor (fits_in_64 (ty_int ty)) x x)) (subsume (iconst ty (imm64 0)))) ;; x ^ not(x) == not(x) ^ x == -1. @@ -167,6 +167,9 @@ (iadd ty x x)) ;; x*c == x<