Skip to content

Commit 8258bb3

Browse files
committed
egraphs: Add comutative versions of the icmp ne thruthy rules
1 parent c1c35a8 commit 8258bb3

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

cranelift/codegen/src/opts/bitops.isle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,14 @@
120120
(rule (truthy (rotr _ x _)) x)
121121
(rule (truthy (select _ x (iconst _ (u64_from_imm64 (u64_nonzero _))) (iconst _ (u64_from_imm64 0)))) x)
122122
(rule (truthy (ne _ x (iconst _ (u64_from_imm64 0)))) x)
123+
(rule (truthy (ne _ (iconst _ (u64_from_imm64 0)) x)) x)
123124

124125
;; All of these expressions don't care about their input as long as it is truthy.
125126
;; so we can remove expressions that preserve that property from the input.
126127
(rule (simplify (bmask ty v)) (if-let x (truthy v)) (bmask ty x))
127128
(rule (simplify (select ty v lhs rhs)) (if-let c (truthy v)) (select ty c lhs rhs))
128129
(rule (simplify (ne ty v zero @ (iconst _ (u64_from_imm64 0)))) (if-let c (truthy v)) (ne ty c zero))
130+
(rule (simplify (ne ty zero @ (iconst _ (u64_from_imm64 0)) v)) (if-let c (truthy v)) (ne ty c zero))
129131

130132

131133
;; (sextend (bmask x)) can be replaced with (bmask x) since bmask

0 commit comments

Comments
 (0)