Skip to content

Commit eb4c527

Browse files
Fix another panic optimizing vector expressions (#12961)
Leftover from #12957
1 parent 122ddc7 commit eb4c527

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

cranelift/codegen/src/opts/arithmetic.isle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,5 +386,5 @@
386386
(rule (simplify (eq (ty_int ty) (iadd cty y x) (iadd cty y x))) (iconst_u ty 1))
387387

388388
;; (x - y) != x --> y != 0
389-
(rule (simplify (ne cty (isub ty x y) x)) (ne cty y (iconst_u ty 0)))
390-
(rule (simplify (ne cty x (isub ty x y))) (ne cty y (iconst_u ty 0)))
389+
(rule (simplify (ne cty (isub (ty_int ty) x y) x)) (ne cty y (iconst_u ty 0)))
390+
(rule (simplify (ne cty x (isub (ty_int ty) x y))) (ne cty y (iconst_u ty 0)))

cranelift/filetests/filetests/egraph/arithmetic-precise.clif

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,3 +263,18 @@ block0(v0: i32, v1: i32):
263263
; v5 = icmp ne v1, v4 ; v4 = 0
264264
; return v5
265265
; }
266+
267+
;; (x - y) != x --> y != 0 (vector)
268+
function %simplify_vector_icmp_ne_isub_x(i32x4, i32x4) -> i32x4 fast {
269+
block0(v0: i32x4, v1: i32x4):
270+
v2 = isub v0, v1
271+
v3 = icmp ne v2, v0
272+
return v3
273+
}
274+
275+
; function %simplify_vector_icmp_ne_isub_x(i32x4, i32x4) -> i32x4 fast {
276+
; block0(v0: i32x4, v1: i32x4):
277+
; v2 = isub v0, v1
278+
; v3 = icmp ne v2, v0
279+
; return v3
280+
; }

0 commit comments

Comments
 (0)