-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[mlir][arith] mul operation regressions #96975
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6799820
mul regressions
pingshiyu 3edd5f7
reindented
pingshiyu 041601a
multiplication tests refactored
pingshiyu 6c5ae89
added equivalent reprs
pingshiyu e13fcb7
added labels, merged test functions together
pingshiyu 22bf762
removed function return values
pingshiyu a2068a1
updates based on comments
pingshiyu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
mlir/test/Integration/Dialect/Arith/CPU/multiplication.mlir
This file contains hidden or 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,98 @@ | ||
// Tests mul operations and their variants (e.g. extended). | ||
// These tests are intended to be target agnostic: they should yield the same results | ||
// regardless of the target platform. | ||
|
||
// RUN: mlir-opt %s --convert-scf-to-cf --convert-cf-to-llvm --convert-vector-to-llvm \ | ||
// RUN: --convert-func-to-llvm --convert-arith-to-llvm | \ | ||
// RUN: mlir-cpu-runner -e entry -entry-point-result=void \ | ||
// RUN: --shared-libs=%mlir_c_runner_utils | \ | ||
// RUN: FileCheck %s --match-full-lines | ||
|
||
func.func @mulsi_extended_i1(%v1 : i1, %v2 : i1) -> (i1, i1) { | ||
%low, %high = arith.mulsi_extended %v1, %v2 : i1 | ||
vector.print %low : i1 | ||
vector.print %high : i1 | ||
func.return %low, %high : i1, i1 | ||
} | ||
|
||
func.func @mulsi_extended_on_i1() { | ||
pingshiyu marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
// mulsi_extended on i1, tests for overflow bit | ||
// mulsi_extended 1, 1 : i1 = (1, 0) | ||
%true = arith.constant true | ||
%false = arith.constant false | ||
|
||
// CHECK: 1 | ||
// CHECK-NEXT: 0 | ||
func.call @mulsi_extended_i1(%true, %true) : (i1, i1) -> (i1, i1) | ||
|
||
// CHECK-NEXT: 0 | ||
// CHECK-NEXT: 0 | ||
func.call @mulsi_extended_i1(%true, %false) : (i1, i1) -> (i1, i1) | ||
|
||
// CHECK-NEXT: 0 | ||
// CHECK-NEXT: 0 | ||
func.call @mulsi_extended_i1(%false, %true) : (i1, i1) -> (i1, i1) | ||
|
||
// CHECK-NEXT: 0 | ||
// CHECK-NEXT: 0 | ||
func.call @mulsi_extended_i1(%false, %false) : (i1, i1) -> (i1, i1) | ||
|
||
return | ||
} | ||
|
||
func.func @mulsi_extended_i8(%v1 : i8, %v2 : i8) -> (i8, i8) { | ||
%low, %high = arith.mulsi_extended %v1, %v2 : i8 | ||
vector.print %low : i8 | ||
vector.print %high : i8 | ||
func.return %low, %high : i8, i8 | ||
} | ||
|
||
func.func @mulsi_extended_overflows() { | ||
// mulsi extended versions, with overflow | ||
%c_100_i8 = arith.constant -100 : i8 | ||
|
||
// mulsi_extended -100, -100 : i8 = (16, 39) | ||
// CHECK-NEXT: 16 | ||
// CHECK-NEXT: 39 | ||
func.call @mulsi_extended_i8(%c_100_i8, %c_100_i8) : (i8, i8) -> (i8, i8) | ||
return | ||
} | ||
|
||
func.func @mului_extended_i8(%v1 : i8, %v2 : i8) -> (i8, i8) { | ||
%low, %high = arith.mului_extended %v1, %v2 : i8 | ||
vector.print %low : i8 | ||
vector.print %high : i8 | ||
func.return %low, %high : i8, i8 | ||
} | ||
|
||
func.func @mului_extended_overflows() -> () { | ||
%c_n100_i8 = arith.constant -100 : i8 | ||
%c_156_i8 = arith.constant 156 : i8 | ||
|
||
// mului_extended -100, -100 : i8 = (16, 95) | ||
// and on equivalent representations (e.g. 156 === -100 (mod 256)) | ||
|
||
// CHECK-NEXT: 16 | ||
// CHECK-NEXT: 95 | ||
func.call @mului_extended_i8(%c_n100_i8, %c_n100_i8) : (i8, i8) -> (i8, i8) | ||
|
||
// CHECK-NEXT: 16 | ||
// CHECK-NEXT: 95 | ||
func.call @mului_extended_i8(%c_n100_i8, %c_156_i8) : (i8, i8) -> (i8, i8) | ||
|
||
// CHECK-NEXT: 16 | ||
// CHECK-NEXT: 95 | ||
func.call @mului_extended_i8(%c_156_i8, %c_n100_i8) : (i8, i8) -> (i8, i8) | ||
|
||
// CHECK-NEXT: 16 | ||
// CHECK-NEXT: 95 | ||
func.call @mului_extended_i8(%c_156_i8, %c_156_i8) : (i8, i8) -> (i8, i8) | ||
return | ||
} | ||
|
||
func.func @entry() { | ||
func.call @mulsi_extended_on_i1() : () -> () | ||
func.call @mulsi_extended_overflows() : () -> () | ||
func.call @mului_extended_overflows() : () -> () | ||
return | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.