Generalize u/sextend constant folding to all types (#5706)
Also move these optimization rules to cprop.isle; it's where all the other similar rules are. Like the other cprop rules, these can subsume any other rules. We can't do better than reducing an expression to a constant. The new i64_sextend_imm64 and u64_uextend_imm64 constructors are useful helpers to clean up other code. I applied them to `imm64_icmp` while I was here, as well as using the existing `ty_mask` helper to clean up `imm64_masked`.
This commit is contained in:
@@ -6,12 +6,6 @@
|
||||
;; 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`.
|
||||
|
||||
;; uextend/sextend of a constant.
|
||||
(rule (simplify (uextend $I64 (iconst $I32 (u64_from_imm64 imm))))
|
||||
(iconst $I64 (imm64 (u64_uextend_u32 imm))))
|
||||
(rule (simplify (sextend $I64 (iconst $I32 (u64_from_imm64 imm))))
|
||||
(iconst $I64 (imm64 (u64_sextend_u32 imm))))
|
||||
|
||||
;; x+0 == 0+x == x.
|
||||
(rule (simplify (iadd ty
|
||||
x
|
||||
|
||||
@@ -70,6 +70,12 @@
|
||||
(iconst _ k2)))
|
||||
(subsume (iconst ty (imm64_sshr ty k1 k2))))
|
||||
|
||||
(rule (simplify (uextend wide (iconst narrow imm)))
|
||||
(subsume (iconst wide (imm64 (u64_uextend_imm64 narrow imm)))))
|
||||
|
||||
(rule (simplify (sextend wide (iconst narrow imm)))
|
||||
(subsume (iconst wide (imm64_masked wide (i64_as_u64 (i64_sextend_imm64 narrow imm))))))
|
||||
|
||||
(rule (simplify
|
||||
(icmp result_ty
|
||||
cc
|
||||
|
||||
Reference in New Issue
Block a user