Skip to content

Commit 05277cf

Browse files
authored
Fix ISLE optimization for vector inputs (#12179)
Add some more `fits_in_64` constraints to types to handle the fact that `iconst_u` can't construct a 128-bit output. Closes #12170
1 parent 23b2fe3 commit 05277cf

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

cranelift/codegen/src/opts/selects.isle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,14 @@
103103
(rule (simplify (select ty d (select ty d x _) a)) (select ty d x a))
104104

105105
;; min x y < x => false and its commutative versions
106-
(rule (simplify (sgt ty (smin _ x y) x)) (iconst_u ty 0))
107-
(rule (simplify (sgt ty (smin _ x y) y)) (iconst_u ty 0))
108-
(rule (simplify (slt ty x (smin _ x z))) (iconst_u ty 0))
109-
(rule (simplify (slt ty x (smin _ y x))) (iconst_u ty 0))
110-
(rule (simplify (ugt ty (umin _ x y) x)) (iconst_u ty 0))
111-
(rule (simplify (ugt ty (umin _ x y) y)) (iconst_u ty 0))
112-
(rule (simplify (ult ty x (umin _ x z))) (iconst_u ty 0))
113-
(rule (simplify (ult ty x (umin _ y x))) (iconst_u ty 0))
106+
(rule (simplify (sgt (fits_in_64 ty) (smin _ x y) x)) (iconst_u ty 0))
107+
(rule (simplify (sgt (fits_in_64 ty) (smin _ x y) y)) (iconst_u ty 0))
108+
(rule (simplify (slt (fits_in_64 ty) x (smin _ x z))) (iconst_u ty 0))
109+
(rule (simplify (slt (fits_in_64 ty) x (smin _ y x))) (iconst_u ty 0))
110+
(rule (simplify (ugt (fits_in_64 ty) (umin _ x y) x)) (iconst_u ty 0))
111+
(rule (simplify (ugt (fits_in_64 ty) (umin _ x y) y)) (iconst_u ty 0))
112+
(rule (simplify (ult (fits_in_64 ty) x (umin _ x z))) (iconst_u ty 0))
113+
(rule (simplify (ult (fits_in_64 ty) x (umin _ y x))) (iconst_u ty 0))
114114

115115

116116

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
(module
2+
(func (export "hi") (result v128)
3+
(local $i v128)
4+
v128.const i64x2 0xfa2675c080000000 0xe8a433230a7479e5
5+
local.set $i
6+
local.get $i
7+
local.get $i
8+
local.get $i
9+
i32x4.min_s
10+
i32x4.lt_s
11+
)
12+
13+
)

0 commit comments

Comments
 (0)