-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[mlir][LLVM] Add nneg flag #115498
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
[mlir][LLVM] Add nneg flag #115498
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -146,6 +146,9 @@ static void printLLVMOpAttrs(OpAsmPrinter &printer, Operation *op, | |
| } else if (auto iface = dyn_cast<ExactFlagInterface>(op)) { | ||
| printer.printOptionalAttrDict(filteredAttrs, | ||
| /*elidedAttrs=*/{iface.getIsExactName()}); | ||
| } else if (auto iface = dyn_cast<NonNegFlagInterface>(op)) { | ||
| printer.printOptionalAttrDict(filteredAttrs, | ||
|
||
| /*elidedAttrs=*/{iface.getNonNegName()}); | ||
| } else { | ||
| printer.printOptionalAttrDict(filteredAttrs); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -325,6 +325,19 @@ func.func @casts(%arg0: i32, %arg1: i64, %arg2: vector<4xi32>, | |||||
| llvm.return | ||||||
| } | ||||||
|
|
||||||
| // CHECK-LABEL: @nneg_casts | ||||||
| // CHECK-SAME: (%[[I32:.*]]: i32, %[[I64:.*]]: i64, %[[V4I32:.*]]: vector<4xi32>, %[[V4I64:.*]]: vector<4xi64>, %[[PTR:.*]]: !llvm.ptr) | ||||||
| func.func @nneg_casts(%arg0: i32, %arg1: i64, %arg2: vector<4xi32>, | ||||||
| %arg3: vector<4xi64>, %arg4: !llvm.ptr) { | ||||||
| // CHECK: = llvm.zext nneg %[[I32]] : i32 to i64 | ||||||
| %0 = llvm.zext nneg %arg0 : i32 to i64 | ||||||
| // CHECK: = llvm.zext nneg %[[V4I32]] : vector<4xi32> to vector<4xi64> | ||||||
| %4 = llvm.zext nneg %arg2 : vector<4xi32> to vector<4xi64> | ||||||
| // CHECK: %[[FLOAT:.*]] = llvm.uitofp nneg %[[I32]] : i32 to f32 | ||||||
|
||||||
| // CHECK: %[[FLOAT:.*]] = llvm.uitofp nneg %[[I32]] : i32 to f32 | |
| // CHECK: = llvm.uitofp nneg %[[I32]] : i32 to f32 |
nit: I would drop the variable since it has no uses in this test.
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.
Done!
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ; RUN: mlir-translate -import-llvm -split-input-file %s | FileCheck %s | ||
|
|
||
| ; CHECK-LABEL: @nnegflag_inst | ||
| define void @nnegflag_inst(i32 %arg1) { | ||
| ; CHECK: llvm.zext nneg %{{.*}} : i32 to i64 | ||
| %1 = zext nneg i32 %arg1 to i64 | ||
| ; CHECK: llvm.uitofp nneg %{{.*}} : i32 to f32 | ||
| %2 = uitofp nneg i32 %arg1 to float | ||
| ret void | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| // RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
|
|
||
| // CHECK-LABEL: define void @nnegflag_func | ||
| llvm.func @nnegflag_func(%arg0: i32) { | ||
| // CHECK: %{{.*}} = zext nneg i32 %{{.*}} to i64 | ||
| %0 = llvm.zext nneg %arg0 : i32 to i64 | ||
| // CHECK: %{{.*}} = uitofp nneg i32 %{{.*}} to float | ||
| %1 = llvm.uitofp nneg %arg0 : i32 to f32 | ||
| llvm.return | ||
| } |
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.
ultra nit:
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.
Done!