cranelift: simplify x-x to 0 (#6032)
* cranelift: simplify `x-x` to `0` * Guard `x-x => 0` rewrite with `fits_in_64`
This commit is contained in:
@@ -35,6 +35,9 @@
|
||||
;; ineg(ineg(x)) == x.
|
||||
(rule (simplify (ineg ty (ineg ty x))) (subsume x))
|
||||
|
||||
;; x-x == 0.
|
||||
(rule (simplify (isub (fits_in_64 (ty_int ty)) x x)) (subsume (iconst ty (imm64 0))))
|
||||
|
||||
;; x*1 == 1*x == x.
|
||||
(rule (simplify (imul ty
|
||||
x
|
||||
|
||||
@@ -232,6 +232,14 @@ block0(v0: i32):
|
||||
; check: return v0
|
||||
}
|
||||
|
||||
function %isub_self(i32) -> i32 {
|
||||
block0(v0: i32):
|
||||
v1 = isub v0, v0
|
||||
return v1
|
||||
; check: v2 = iconst.i32 0
|
||||
; check: return v2
|
||||
}
|
||||
|
||||
function %or_and_y_with_not_y_i8(i8, i8) -> i8 {
|
||||
block0(v0: i8, v1: i8):
|
||||
v2 = band v0, v1
|
||||
|
||||
Reference in New Issue
Block a user