[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
This commit is contained in:
Kiran Chandramohan 2023-07-18 09:09:58 +00:00
parent 505335a99d
commit 41f478f041
2 changed files with 15 additions and 1 deletions

View File

@ -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<fir::LogicalType>(lhsEleTy) !=

View File

@ -70,3 +70,15 @@ endsubroutine
! CHECK-NEXT: hlfir.assign %[[PROD]] to %[[RES_VAR]]#0 : i32, !fir.ref<i32>
! CHECK-NEXT: return
! CHECK-NEXT: }
! CHECK-LABEL: func.func @_QPdot_product5
! CHECK: %[[LHS:.*]]:2 = hlfir.declare %{{.*}} {uniq_name = "_QFdot_product5Elhs"} : (!fir.box<!fir.array<?xi32>>) -> (!fir.box<!fir.array<?xi32>>, !fir.box<!fir.array<?xi32>>)
! 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.array<3xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<3xi32>>, !fir.ref<!fir.array<3xi32>>)
! CHECK: {{.*}} = hlfir.dot_product %[[LHS]]#0 %[[RHS]]#0 {fastmath = #arith.fastmath<contract>} : (!fir.box<!fir.array<?xi32>>, !fir.ref<!fir.array<3xi32>>) -> i32
subroutine dot_product5(lhs, rhs, res)
integer :: lhs(:), rhs(3)
integer :: res
res = dot_product(lhs, rhs)
endsubroutine