From: Kiran Chandramohan Date: Tue, 18 Jul 2023 09:09:58 +0000 (+0000) Subject: [Flang][HLFIR] Relax size check for dot_product intrinsic X-Git-Tag: upstream/17.0.6~1389 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=41f478f0419781f6968de0661ce570916c9de863;p=platform%2Fupstream%2Fllvm.git [Flang][HLFIR] Relax size check for dot_product intrinsic If the size of one of the operand arrays is not known at compile time, do not issue a size mismatch error sinc they could match at runtime. Fixes the compilation error in polyhedron/induct2. Reviewed By: tblah, vzakhari Differential Revision: https://reviews.llvm.org/D155302 --- diff --git a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp index 51b44d7..37a1d9a 100644 --- a/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp +++ b/flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp @@ -733,7 +733,9 @@ mlir::LogicalResult hlfir::DotProductOp::verify() { int64_t lhsSize = lhsShape[0]; int64_t rhsSize = rhsShape[0]; - if (lhsSize != rhsSize) + constexpr int64_t unknownExtent = fir::SequenceType::getUnknownExtent(); + if ((lhsSize != unknownExtent) && (rhsSize != unknownExtent) && + (lhsSize != rhsSize)) return emitOpError("both arrays must have the same size"); if (mlir::isa(lhsEleTy) != diff --git a/flang/test/Lower/HLFIR/dot_product.f90 b/flang/test/Lower/HLFIR/dot_product.f90 index 47e623a..890dc4a 100644 --- a/flang/test/Lower/HLFIR/dot_product.f90 +++ b/flang/test/Lower/HLFIR/dot_product.f90 @@ -70,3 +70,15 @@ endsubroutine ! CHECK-NEXT: hlfir.assign %[[PROD]] to %[[RES_VAR]]#0 : i32, !fir.ref ! CHECK-NEXT: return ! CHECK-NEXT: } + +! CHECK-LABEL: func.func @_QPdot_product5 +! CHECK: %[[LHS:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFdot_product5Elhs"} : (!fir.box>) -> (!fir.box>, !fir.box>) +! CHECK: %[[C3:.*]] = arith.constant 3 : index +! CHECK: %[[RHS_SHAPE:.*]] = fir.shape %[[C3]] : (index) -> !fir.shape<1> +! CHECK: %[[RHS:.*]]:2 = hlfir.declare %{{.*}}(%[[RHS_SHAPE]]) {uniq_name = "_QFdot_product5Erhs"} : (!fir.ref>, !fir.shape<1>) -> (!fir.ref>, !fir.ref>) +! CHECK: {{.*}} = hlfir.dot_product %[[LHS]]#0 %[[RHS]]#0 {fastmath = #arith.fastmath} : (!fir.box>, !fir.ref>) -> i32 +subroutine dot_product5(lhs, rhs, res) + integer :: lhs(:), rhs(3) + integer :: res + res = dot_product(lhs, rhs) +endsubroutine