Cranelift: Add(and modify) simplification rules#13850
Conversation
8acf908 to
b60f059
Compare
Subscribe to Label ActionDetailsThis issue or pull request has been labeled: "cranelift", "isle"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
fitzgen
left a comment
There was a problem hiding this comment.
LGTM, modulo one small concern below. Thanks!
| function %test_bxor_x_x_i64x2(i64x2) -> i64x2 fast { | ||
| block0(v0: i64x2): | ||
| v1 = bxor v0, v0 | ||
| return v1 | ||
| } | ||
|
|
||
| ; run: %test_bxor_x_x_i64x2([0 0]) == [0 0] | ||
| ; run: %test_bxor_x_x_i64x2([0x123456789abcdef0 0xffffffffffffffff]) == [0 0] |
There was a problem hiding this comment.
Ah okay, here is the test.
Can we also exercise floats and a vector of floats? Thanks!
b60f059 to
8b4249a
Compare
|
@fitzgen As you suspected, |
[Cranelift] add simplification rules
8b4249a to
1999068
Compare
| (iconst_u ty 0))) | ||
| (subsume x)) | ||
|
|
||
| ;; Create an all-zero bit pattern for integer, float, and vector types. |
There was a problem hiding this comment.
Add an all-zero helper for float and vector types.
fitzgen
left a comment
There was a problem hiding this comment.
Thanks! One last question below about the new all_zero helper
| (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)))) |
There was a problem hiding this comment.
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 ir::Constants, but they would be easy to add if necessary.
But if splatting is expected to be more efficient, then we should add a comment to that effect here.
Add and modify simplification rules.
arithmetic.isle
-(~x) --> x + 1~(-x) --> x - 1-1 - x --> ~xbitops.isle
x ^ x --> 0to support vector types.extends.isle
icmp.isle
~x == x --> 0,~x != x --> 1x == x --> 1to support vector types.shifts.isle
For example,
0 << x --> 0or(-1) >>s x --> (-1).