Cranelift: Collapse double extends into a single extend (#5772)

This commit is contained in:
Nick Fitzgerald
2023-02-13 14:43:17 -08:00
committed by GitHub
parent 91c8114f00
commit 6df3bbbe60
2 changed files with 26 additions and 0 deletions

View File

@@ -6,6 +6,12 @@
;; than a piece of the input or a new node that we construct; but we
;; can freely rewrite e.g. `x+y-y` to `x`.
;; Chained `uextend` and `sextend`.
(rule (simplify (uextend ty (uextend _intermediate_ty x)))
(uextend ty x))
(rule (simplify (sextend ty (sextend _intermediate_ty x)))
(sextend ty x))
;; x+0 == 0+x == x.
(rule (simplify (iadd ty
x

View File

@@ -337,3 +337,23 @@ block0(v1: i32):
; check: v5 = iconst.i8 1
; check: return v5
function %double_uextend(i16) -> i64 {
block0(v1: i16):
v2 = uextend.i32 v1
v3 = uextend.i64 v2
return v3
}
; check: v4 = uextend.i64 v1
; check: return v4
function %double_sextend(i16) -> i64 {
block0(v1: i16):
v2 = sextend.i32 v1
v3 = sextend.i64 v2
return v3
}
; check: v4 = sextend.i64 v1
; check: return v4