@@ -264,17 +264,171 @@ block0(v0: i32, v1: i32):
264264; return v5
265265; }
266266
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 ):
267+ ;; (x - y) == x --> y == 0
268+ function %test_eq_isub_same(i32, i32 ) -> i8 fast {
269+ block0(v0: i32 , v1: i32 ):
270270 v2 = isub v0, v1
271- v3 = icmp ne v2, v0
271+ v3 = icmp eq v2, v0
272272 return v3
273273}
274274
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
275+ ; function %test_eq_isub_same(i32, i32) -> i8 fast {
276+ ; block0(v0: i32, v1: i32):
277+ ; v4 = iconst.i32 0
278+ ; v5 = icmp eq v1, v4 ; v4 = 0
279+ ; return v5
280+ ; }
281+
282+ ;; (x + y) == y --> x == 0
283+ function %test_eq_iadd_same_rhs(i32, i32) -> i8 fast {
284+ block0(v0: i32, v1: i32):
285+ v2 = iadd v0, v1
286+ v3 = icmp eq v2, v1
287+ return v3
288+ }
289+
290+ ; function %test_eq_iadd_same_rhs(i32, i32) -> i8 fast {
291+ ; block0(v0: i32, v1: i32):
292+ ; v4 = iconst.i32 0
293+ ; v5 = icmp eq v0, v4 ; v4 = 0
294+ ; return v5
295+ ; }
296+
297+ ;; -x == -y --> x == y
298+ function %test_eq_ineg_ineg(i32, i32) -> i8 fast {
299+ block0(v0: i32, v1: i32):
300+ v2 = ineg v0
301+ v3 = ineg v1
302+ v4 = icmp eq v2, v3
303+ return v4
304+ }
305+
306+ ; function %test_eq_ineg_ineg(i32, i32) -> i8 fast {
307+ ; block0(v0: i32, v1: i32):
308+ ; v2 = ineg v0
309+ ; v3 = ineg v1
310+ ; v4 = icmp eq v2, v3
311+ ; return v4
312+ ; }
313+
314+ ;; -((-y) * x) --> x * y
315+ function %test_ineg_imul_ineg_lhs(i32, i32) -> i32 fast {
316+ block0(v0: i32, v1: i32):
317+ v2 = ineg v1
318+ v3 = imul v2, v0
319+ v4 = ineg v3
320+ return v4
321+ }
322+
323+ ; function %test_ineg_imul_ineg_lhs(i32, i32) -> i32 fast {
324+ ; block0(v0: i32, v1: i32):
325+ ; v5 = imul v0, v1
326+ ; return v5
327+ ; }
328+
329+ function %test_ineg_imul_ineg_rhs(i32, i32) -> i32 fast {
330+ block0(v0: i32, v1: i32):
331+ v2 = ineg v1
332+ v3 = imul v0, v2
333+ v4 = ineg v3
334+ return v4
335+ }
336+
337+ ; function %test_ineg_imul_ineg_rhs(i32, i32) -> i32 fast {
338+ ; block0(v0: i32, v1: i32):
339+ ; v5 = imul v0, v1
340+ ; return v5
341+ ; }
342+
343+ ;; ireduce(sextend(x) + uextend(y)) --> x + y
344+ function %test_ireduce_iadd_extends(i8, i8) -> i8 fast {
345+ block0(v0: i8, v1: i8):
346+ v2 = sextend.i16 v0
347+ v3 = uextend.i16 v1
348+ v4 = iadd v2, v3
349+ v5 = ireduce.i8 v4
350+ return v5
351+ }
352+
353+ ; function %test_ireduce_iadd_extends(i8, i8) -> i8 fast {
354+ ; block0(v0: i8, v1: i8):
355+ ; v6 = iadd v0, v1
356+ ; return v6
357+ ; }
358+
359+ ;; ireduce(sextend(x) - uextend(y)) --> x - y
360+ function %test_ireduce_isub_extends(i8, i8) -> i8 fast {
361+ block0(v0: i8, v1: i8):
362+ v2 = sextend.i16 v0
363+ v3 = uextend.i16 v1
364+ v4 = isub v2, v3
365+ v5 = ireduce.i8 v4
366+ return v5
367+ }
368+
369+ ; function %test_ireduce_isub_extends(i8, i8) -> i8 fast {
370+ ; block0(v0: i8, v1: i8):
371+ ; v6 = isub v0, v1
372+ ; return v6
373+ ; }
374+
375+ ;; smax(x, y) >= x --> true
376+ function %test_sge_smax_x(i32, i32) -> i8 fast {
377+ block0(v0: i32, v1: i32):
378+ v2 = smax v0, v1
379+ v3 = icmp sge v2, v0
380+ return v3
381+ }
382+
383+ ; function %test_sge_smax_x(i32, i32) -> i8 fast {
384+ ; block0(v0: i32, v1: i32):
385+ ; v2 = smax v0, v1
386+ ; v3 = icmp sge v2, v0
387+ ; return v3
388+ ; }
389+
390+ ;; x <=_u umax(x, y) --> true
391+ function %test_ule_x_umax(i32, i32) -> i8 fast {
392+ block0(v0: i32, v1: i32):
393+ v2 = umax v0, v1
394+ v3 = icmp ule v0, v2
395+ return v3
396+ }
397+
398+ ; function %test_ule_x_umax(i32, i32) -> i8 fast {
399+ ; block0(v0: i32, v1: i32):
400+ ; v2 = umax v0, v1
401+ ; v3 = icmp ule v0, v2
279402; return v3
280403; }
404+
405+ ;; x >= smin(x, y) --> true
406+ function %test_sge_x_smin(i32, i32) -> i8 fast {
407+ block0(v0: i32, v1: i32):
408+ v2 = smin v0, v1
409+ v3 = icmp sge v0, v2
410+ return v3
411+ }
412+
413+ ; function %test_sge_x_smin(i32, i32) -> i8 fast {
414+ ; block0(v0: i32, v1: i32):
415+ ; v2 = smin v0, v1
416+ ; v3 = icmp sge v0, v2
417+ ; return v3
418+ ; }
419+
420+ ;; umin(x, y) <=_u x --> true
421+ function %test_ule_umin_x(i32, i32) -> i8 fast {
422+ block0(v0: i32, v1: i32):
423+ v2 = umin v0, v1
424+ v3 = icmp ule v2, v0
425+ return v3
426+ }
427+
428+ ; function %test_ule_umin_x(i32, i32) -> i8 fast {
429+ ; block0(v0: i32, v1: i32):
430+ ; v2 = umin v0, v1
431+ ; v3 = icmp ule v2, v0
432+ ; return v3
433+ ; }
434+
0 commit comments