-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dialects: (builtin) add IntegerAttr truncation and use in individual …
…rewrite (#3585) Adds an option to truncate the bits of an integer to the appropriate size for an `IntegerAttr`. Fixes `AdditionOfSameVariablesToMultiplyByTwo` for `i1` using this truncation.
- Loading branch information
Showing
5 changed files
with
64 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
tests/filecheck/transforms/individual_rewrite/add-same.mlir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// RUN:xdsl-opt %s --split-input-file -p 'apply-individual-rewrite{matched_operation_index=2 operation_name="arith.addi" pattern_name="AdditionOfSameVariablesToMultiplyByTwo"}'| filecheck %s | ||
|
||
|
||
// CHECK: %v = "test.op"() : () -> i32 | ||
// CHECK-NEXT: %[[#two:]] = arith.constant 2 : i32 | ||
// CHECK-NEXT: %{{.*}} = arith.muli %v, %[[#two]] : i32 | ||
|
||
%v = "test.op"() : () -> (i32) | ||
%1 = arith.addi %v, %v : i32 | ||
|
||
// ----- | ||
|
||
// CHECK: %v = "test.op"() : () -> i1 | ||
// CHECK-NEXT: %[[#zero:]] = arith.constant false | ||
// CHECK-NEXT: %{{.*}} = arith.muli %v, %[[#zero]] : i1 | ||
|
||
%v = "test.op"() : () -> (i1) | ||
%1 = arith.addi %v, %v : i1 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters