Browse Source
cranelift: Const Propagate `ireduce` (#6683)
* cranelift: Const Propagate `ireduce`
* cranelift: Use `fits_in_64` in ireduce rule
pull/6694/head
Afonso Bordado
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
33 additions and
0 deletions
-
cranelift/codegen/src/opts/cprop.isle
-
cranelift/filetests/filetests/egraph/cprop.clif
|
|
@ -70,6 +70,9 @@ |
|
|
|
(iconst _ k2))) |
|
|
|
(subsume (iconst ty (imm64_sshr ty k1 k2)))) |
|
|
|
|
|
|
|
(rule (simplify (ireduce narrow (iconst (fits_in_64 _) (u64_from_imm64 imm)))) |
|
|
|
(subsume (iconst narrow (imm64_masked narrow imm)))) |
|
|
|
|
|
|
|
(rule (simplify (uextend (fits_in_64 wide) (iconst narrow imm))) |
|
|
|
(subsume (iconst wide (imm64 (u64_uextend_imm64 narrow imm))))) |
|
|
|
|
|
|
|
|
|
@ -230,3 +230,33 @@ block0: |
|
|
|
|
|
|
|
; check: v3 = iconst.i8 0 |
|
|
|
; nextln: return v3 |
|
|
|
|
|
|
|
function %ireduce_iconst() -> i8 { |
|
|
|
block0: |
|
|
|
v1 = iconst.i16 -10 |
|
|
|
v2 = ireduce.i8 v1 |
|
|
|
return v2 |
|
|
|
} |
|
|
|
|
|
|
|
; check: v3 = iconst.i8 246 |
|
|
|
; nextln: return v3 |
|
|
|
|
|
|
|
function %sextend_iconst() -> i32 { |
|
|
|
block0: |
|
|
|
v1 = iconst.i16 -10 |
|
|
|
v2 = sextend.i32 v1 |
|
|
|
return v2 |
|
|
|
} |
|
|
|
|
|
|
|
; check: v3 = iconst.i32 0xffff_fff6 |
|
|
|
; nextln: return v3 |
|
|
|
|
|
|
|
function %uextend_iconst() -> i32 { |
|
|
|
block0: |
|
|
|
v1 = iconst.i16 0xfff6 |
|
|
|
v2 = uextend.i32 v1 |
|
|
|
return v2 |
|
|
|
} |
|
|
|
|
|
|
|
; check: v3 = iconst.i32 0xfff6 |
|
|
|
; nextln: return v3 |
|
|
|