-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Cranelift: Add(and modify) simplification rules #13850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,9 +14,17 @@ | |
| (iconst_u ty 0))) | ||
| (subsume x)) | ||
|
|
||
| ;; Create an all-zero bit pattern for integer, float, and vector types. | ||
| (decl rec all_zero (Type) Value) | ||
| (rule 0 (all_zero (ty_int ty)) (iconst_u ty 0)) | ||
| (rule 1 (all_zero $F32) (f32const $F32 (f32_from_uint 0))) | ||
| (rule 2 (all_zero $F64) (f64const $F64 (f64_from_uint 0))) | ||
| (rule 3 (all_zero (ty_vec64 ty)) (splat ty (all_zero (lane_type ty)))) | ||
| (rule 4 (all_zero (ty_vec128 ty)) (splat ty (all_zero (lane_type ty)))) | ||
|
Comment on lines
+22
to
+23
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it more efficient to load zeros by splatting than via loads from the constant pool? It seems like we don't have any terms in the mid-end's prelude for working with But if splatting is expected to be more efficient, then we should add a comment to that effect here. |
||
|
|
||
| ;; x ^ x == 0. | ||
| (rule (simplify (bxor (ty_int ty) x x)) | ||
| (subsume (iconst_u ty 0))) | ||
| (rule (simplify (bxor ty x x)) | ||
|
fitzgen marked this conversation as resolved.
|
||
| (subsume (all_zero ty))) | ||
|
|
||
| ;; x ^ not(x) == not(x) ^ x == x | not(x) == not(x) | x == -1. | ||
| ;; This identity also holds for non-integer types, vectors, and wider types. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an all-zero helper for float and vector types.