Skip to content

Commit

Permalink
Correctly set is_int_min_poison (#3427)
Browse files Browse the repository at this point in the history
As is, is_int_min_poison isn't getting set correctly; the LLVM constant
being passed to the builder is being interpreted as a C++ bool, so it's
always true. Set it correctly and add mlir test to ensure this.
  • Loading branch information
vwbaker committed Mar 21, 2024
1 parent 6b72f57 commit e2f97f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,8 @@ struct AbsIOpConversion
ConversionPatternRewriter &rewriter,
Type elemTy, MultipleOperandsRange operands,
Location loc) const {
auto boolFalse = rewriter.getBoolAttr(false);
auto constFalse = rewriter.create<LLVM::ConstantOp>(loc, boolFalse);
return {rewriter.create<LLVM::AbsOp>(loc, elemTy, operands[0][0],
/*is_int_min_poison=*/constFalse)};
/*is_int_min_poison=*/false)};
}
};

Expand Down
12 changes: 12 additions & 0 deletions test/Conversion/tritongpu_to_llvm.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -1549,3 +1549,15 @@ module attributes {"triton_gpu.compute-capability" = 90 : i32, "triton_gpu.num-c
tt.return
}
}

// -----

#blocked0 = #triton_gpu.blocked<{sizePerThread = [2], threadsPerWarp = [32], warpsPerCTA = [4], order = [0], CTAsPerCGA = [1], CTASplitNum = [1], CTAOrder = [0]}>
module attributes {"triton_gpu.num-ctas" = 1 : i32, "triton_gpu.num-warps" = 4 : i32} {
// CHECK-LABEL: abs_is_int_min_poison
// CHECK: %{{.*}} = "llvm.intr.abs"(%{{.*}}) <{is_int_min_poison = false}> : (i32) -> i32
tt.func @abs_is_int_min_poison(%arg0 : tensor<256xi32, #blocked0>) {
%abs = math.absi %arg0 : tensor<256xi32, #blocked0>
tt.return
}
}

0 comments on commit e2f97f7

Please sign in to comment.