-
Notifications
You must be signed in to change notification settings - Fork 73
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
dialects: (arith) add addi constant propagation #3563
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3563 +/- ##
==========================================
- Coverage 90.39% 90.39% -0.01%
==========================================
Files 467 467
Lines 58857 58870 +13
Branches 5606 5609 +3
==========================================
+ Hits 53206 53216 +10
- Misses 4207 4208 +1
- Partials 1444 1446 +2 ☔ View full report in Codecov by Sentry. |
%zero_plus = arith.addi %c0, %a : i32 | ||
%plus_zero = arith.addi %a, %c0 : i32 | ||
|
||
// CHECK: "test.op"(%a, %a) {"identity addition check"} : (i32, i32) -> () | ||
"test.op"(%one_times, %times_one) {"identity addition check"} : (i32, i32) -> () | ||
|
||
// CHECK: %plus_const = arith.addi %a, %c2 : i32 | ||
%plus_const = arith.addi %c2, %a : i32 | ||
"test.op"(%plus_const) : (i32) -> () |
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.
%zero_plus = arith.addi %c0, %a : i32 | |
%plus_zero = arith.addi %a, %c0 : i32 | |
// CHECK: "test.op"(%a, %a) {"identity addition check"} : (i32, i32) -> () | |
"test.op"(%one_times, %times_one) {"identity addition check"} : (i32, i32) -> () | |
// CHECK: %plus_const = arith.addi %a, %c2 : i32 | |
%plus_const = arith.addi %c2, %a : i32 | |
"test.op"(%plus_const) : (i32) -> () | |
%zero_plus = arith.addi %c0, %a : i32 | |
%plus_zero = arith.addi %a, %c0 : i32 | |
// CHECK: %plus_const = arith.addi %a, %c2 : i32 | |
%plus_const = arith.addi %c2, %a : i32 | |
"test.op"(%plus_const) : (i32) -> () |
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.
Unless I'm missing something, it looks like this is a copy/paste from above, but is not necessary
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.
ooh, it is necessary but should be %zero_plus
and %plus_zero
instead of %one_times
and %times_one
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.
It was also a copy paste
Have fixed the test and resolved the conflict |
Moves constants to the right for an addi operation, similar to what #3557 did for muli. Also replaces
AddImmediateZero
byAddiIdentityRight
, which removes constant zeros on the right of an addition instead of the left of an addition like the previous pattern did.Updates interactive tests (and driveby fixes the constant zero being given the SSA value name %two in this test).