We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
min x y < y => false
1 parent 53d3652 commit 7d41355Copy full SHA for 7d41355
3 files changed
cranelift/codegen/src/opts/selects.isle
@@ -102,3 +102,15 @@
102
(rule (simplify (select ty d a (select ty d _ y))) (select ty d a y))
103
(rule (simplify (select ty d (select ty d x _) a)) (select ty d x a))
104
105
+;; 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))
114
+
115
116
cranelift/filetests/filetests/egraph/selects.clif
@@ -61,3 +61,31 @@ block0(v0: i8):
61
; return v8
62
; }
63
64
+function %test_sgt_select_slt_min(i32, i32) -> i8 fast {
65
+block0(v0: i32, v1: i32):
66
+ v2 = icmp slt v1, v0
67
+ v3 = select v2, v1, v0
68
+ v4 = icmp sgt v3, v0
69
+ return v4
70
+}
71
72
+; function %test_sgt_select_slt_min(i32, i32) -> i8 fast {
73
+; block0(v0: i32, v1: i32):
74
+; v7 = iconst.i8 0
75
+; return v7 ; v7 = 0
76
+; }
77
78
+function %test_ugt_select_ult_min(i32, i32) -> i8 fast {
79
80
+ v2 = icmp ult v1, v0
81
82
+ v4 = icmp ugt v3, v0
83
84
85
86
+; function %test_ugt_select_ult_min(i32, i32) -> i8 fast {
87
88
89
90
91
cranelift/filetests/filetests/runtests/select.clif
@@ -441,3 +441,24 @@ block0(v0: i64, v1: i64):
441
; run: %simplify_select_ult_ne_i64(7, 9) == 0
442
; run: %simplify_select_ult_ne_i64(3, 1) == 1
443
; run: %simplify_select_ult_ne_i64(-1, 42) == 1
444
445
446
447
+ v2 = icmp slt v1, v0 ; (slt y, x)
448
+ v3 = select v2, v1, v0 ; select( (y <_s x), y, x) -> smin(y, x)
449
+ v4 = icmp sgt v3, v0 ; sgt( min(y, x), x )
450
451
452
453
+; run: %test_sgt_select_slt_min(42, 444) == 0
454
455
456
457
+ v2 = icmp ult v1, v0 ; (slt y, x)
458
+ v3 = select v2, v1, v0 ; select( (y <_s x), y, x) -> umin(y, x)
459
+ v4 = icmp ugt v3, v0 ; sgt( min(y, x), x )
460
461
462
463
+; run: %test_ugt_select_ult_min(234234, 5544) == 0
464
0 commit comments