Fix optimization rules for narrow types: wrap i8 results to 8 bits. (#5409)
* Fix optimization rules for narrow types: wrap i8 results to 8 bits. This fixes #5405. In the egraph mid-end's optimization rules, we were rewriting e.g. imuls of two iconsts to an iconst of the result, but without masking off the high bits (beyond the result type's width). This was producing iconsts with set high bits beyond their types' width, which is not legal. In addition, this PR adds some optimizations to the algebraic rules to recognize e.g. `x == x` (and all other integer comparison operators) and resolve to 1 or 0 as appropriate. * Review feedback. * Review feedback, again.
This commit is contained in:
@@ -349,6 +349,10 @@
|
||||
(decl pure imm64 (u64) Imm64)
|
||||
(extern constructor imm64 imm64)
|
||||
|
||||
;; Create a new Imm64, masked to the width of the given type.
|
||||
(decl pure imm64_masked (Type u64) Imm64)
|
||||
(extern constructor imm64_masked imm64_masked)
|
||||
|
||||
;; Extract a `u64` from an `Ieee32`.
|
||||
(decl u64_from_ieee32 (u64) Ieee32)
|
||||
(extern extractor infallible u64_from_ieee32 u64_from_ieee32)
|
||||
|
||||
Reference in New Issue
Block a user