From 47f99500e68e40f34a1dab8b0350f32c2ed62d9d Mon Sep 17 00:00:00 2001
From: Daniel Llorens <lloda@sarc.name>
Date: Thu, 4 Nov 2021 16:02:42 +0100
Subject: [PATCH 2/2] Avoid ash with arguments that might overflow in (language
 cps types)

Fixes https://debbugs.gnu.org/50609

* module/languages/cps/types.scm (ulsh): As stated.
---
 module/language/cps/types.scm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/module/language/cps/types.scm b/module/language/cps/types.scm
index d3be176bf..87c58d5bc 100644
--- a/module/language/cps/types.scm
+++ b/module/language/cps/types.scm
@@ -1444,7 +1444,9 @@ minimum, and maximum."
         (define! result &s64 &s64-min &s64-max))))
 
 (define-type-inferrer (ulsh a b result)
-  (if (<= (ash (&max/u64 a) (&max/u64 b)) &u64-max)
+  (if (and
+       (or (zero? (&max/u64 a)) (< (&max/u64 b) 64)) ; don't even try
+       (<= (ash (&max/u64 a) (&max/u64 b)) &u64-max))
       ;; No overflow; we can be precise.
       (define! result &u64
         (ash (&min/0 a) (&min/0 b))
-- 
2.33.1

