[Mlir-commits] [mlir] b389c80 - [mlir] Fix lowering of multi-dimensional vector log1p to LLVM
Benjamin Kramer
llvmlistbot at llvm.org
Thu Apr 29 12:54:22 PDT 2021
Author: Benjamin Kramer
Date: 2021-04-29T21:53:52+02:00
New Revision: b389c80963fb6276d5df62afe9bd4bd08239887b
URL: https://github.com/llvm/llvm-project/commit/b389c80963fb6276d5df62afe9bd4bd08239887b
DIFF: https://github.com/llvm/llvm-project/commit/b389c80963fb6276d5df62afe9bd4bd08239887b.diff
LOG: [mlir] Fix lowering of multi-dimensional vector log1p to LLVM
This was using the untransformed operand, leading to invalid IR.
Differential Revision: https://reviews.llvm.org/D101531
Added:
Modified:
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index ddfb349cb816a..32ff6b526f2e1 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -2396,7 +2396,7 @@ struct Log1pOpLowering : public ConvertOpToLLVMPattern<math::Log1pOp> {
auto one =
rewriter.create<LLVM::ConstantOp>(loc, llvm1DVectorTy, splatAttr);
auto add = rewriter.create<LLVM::FAddOp>(loc, llvm1DVectorTy, one,
- transformed.operand());
+ operands[0]);
return rewriter.create<LLVM::LogOp>(loc, llvm1DVectorTy, add);
},
rewriter);
diff --git a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
index 1d12eb937378f..b53de92935fe3 100644
--- a/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
+++ b/mlir/test/Conversion/StandardToLLVM/standard-to-llvm.mlir
@@ -24,6 +24,19 @@ func @log1p(%arg0 : f32) {
// -----
+// CHECK-LABEL: func @log1p_2dvector(
+func @log1p_2dvector(%arg0 : vector<4x3xf32>) {
+ // CHECK: %[[EXTRACT:.*]] = llvm.extractvalue %arg0[0] : !llvm.array<4 x vector<3xf32>>
+ // CHECK: %[[ONE:.*]] = llvm.mlir.constant(dense<1.000000e+00> : vector<3xf32>) : vector<3xf32>
+ // CHECK: %[[ADD:.*]] = llvm.fadd %[[ONE]], %[[EXTRACT]] : vector<3xf32>
+ // CHECK: %[[LOG:.*]] = "llvm.intr.log"(%[[ADD]]) : (vector<3xf32>) -> vector<3xf32>
+ // CHECK: %[[INSERT:.*]] = llvm.insertvalue %[[LOG]], %0[0] : !llvm.array<4 x vector<3xf32>>
+ %0 = math.log1p %arg0 : vector<4x3xf32>
+ std.return
+}
+
+// -----
+
// CHECK-LABEL: func @rsqrt(
// CHECK-SAME: f32
func @rsqrt(%arg0 : f32) {
More information about the Mlir-commits
mailing list