[llvm] fix template compilation issue in flang-rt, fix issue #160534 (PR #161250)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 11:03:09 PDT 2025
https://github.com/Nir-Cohen-2003 created https://github.com/llvm/llvm-project/pull/161250
None
>From f70914aaa975f0311c263a71b9acb24dc4ac719c Mon Sep 17 00:00:00 2001
From: Nir Cohen <nircoh at weizmann.ac.il>
Date: Mon, 29 Sep 2025 20:22:37 +0300
Subject: [PATCH] fix template compilation issue in flang-rt, fix issue #160534
---
flang-rt/lib/runtime/matmul-transpose.cpp | 8 ++++----
flang-rt/lib/runtime/matmul.cpp | 10 +++++-----
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/flang-rt/lib/runtime/matmul-transpose.cpp b/flang-rt/lib/runtime/matmul-transpose.cpp
index 789f13c585ec5..29ba6a8915f2e 100644
--- a/flang-rt/lib/runtime/matmul-transpose.cpp
+++ b/flang-rt/lib/runtime/matmul-transpose.cpp
@@ -62,7 +62,7 @@ inline static RT_API_ATTRS void MatrixTransposedTimesMatrix(
std::size_t yColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- Fortran::runtime::memset(product, 0, rows * cols * sizeof *product);
+ std::memset(product, 0, rows * cols * sizeof *product);
for (SubscriptValue j{0}; j < cols; ++j) {
for (SubscriptValue i{0}; i < rows; ++i) {
for (SubscriptValue k{0}; k < n; ++k) {
@@ -132,7 +132,7 @@ inline static RT_API_ATTRS void MatrixTransposedTimesVector(
SubscriptValue n, const XT *RESTRICT x, const YT *RESTRICT y,
std::size_t xColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- Fortran::runtime::memset(product, 0, rows * sizeof *product);
+ std::memset(product, 0, rows * sizeof *product);
for (SubscriptValue i{0}; i < rows; ++i) {
for (SubscriptValue k{0}; k < n; ++k) {
ResultType x_ki;
@@ -340,8 +340,8 @@ struct MatmulTransposeHelper {
RUNTIME_CHECK(terminator, xCatKind.has_value() && yCatKind.has_value());
RUNTIME_CHECK(terminator, xCatKind->first == XCAT);
RUNTIME_CHECK(terminator, yCatKind->first == YCAT);
- if constexpr (constexpr ResultTy resultType{
- GetResultType(XCAT, XKIND, YCAT, YKIND)}) {
+ constexpr ResultTy resultType{GetResultType(XCAT, XKIND, YCAT, YKIND)};
+ if constexpr (resultType) {
return DoMatmulTranspose<IS_ALLOCATING, resultType->first,
resultType->second, CppTypeFor<XCAT, XKIND>, CppTypeFor<YCAT, YKIND>>(
result, x, y, terminator);
diff --git a/flang-rt/lib/runtime/matmul.cpp b/flang-rt/lib/runtime/matmul.cpp
index d409cb1458c90..0e398c018d55d 100644
--- a/flang-rt/lib/runtime/matmul.cpp
+++ b/flang-rt/lib/runtime/matmul.cpp
@@ -81,7 +81,7 @@ inline RT_API_ATTRS void MatrixTimesMatrix(
SubscriptValue n, std::size_t xColumnByteStride = 0,
std::size_t yColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- Fortran::runtime::memset(product, 0, rows * cols * sizeof *product);
+ std::memset(product, 0, rows * cols * sizeof *product);
const XT *RESTRICT xp0{x};
for (SubscriptValue k{0}; k < n; ++k) {
ResultType *RESTRICT p{product};
@@ -153,7 +153,7 @@ inline RT_API_ATTRS void MatrixTimesVector(
SubscriptValue n, const XT *RESTRICT x, const YT *RESTRICT y,
std::size_t xColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- Fortran::runtime::memset(product, 0, rows * sizeof *product);
+ std::memset(product, 0, rows * sizeof *product);
[[maybe_unused]] const XT *RESTRICT xp0{x};
for (SubscriptValue k{0}; k < n; ++k) {
ResultType *RESTRICT p{product};
@@ -203,7 +203,7 @@ inline RT_API_ATTRS void VectorTimesMatrix(
SubscriptValue cols, const XT *RESTRICT x, const YT *RESTRICT y,
std::size_t yColumnByteStride = 0) {
using ResultType = CppTypeFor<RCAT, RKIND>;
- Fortran::runtime::memset(product, 0, cols * sizeof *product);
+ std::memset(product, 0, cols * sizeof *product);
for (SubscriptValue k{0}; k < n; ++k) {
ResultType *RESTRICT p{product};
auto xv{static_cast<ResultType>(*x++)};
@@ -440,8 +440,8 @@ struct MatmulHelper {
xCatKind->first == TypeCategory::Unsigned) &&
(yCatKind->first == TypeCategory::Integer ||
yCatKind->first == TypeCategory::Unsigned))));
- if constexpr (constexpr ResultTy resultType{
- GetResultType(XCAT, XKIND, YCAT, YKIND)}) {
+ constexpr ResultTy resultType{GetResultType(XCAT, XKIND, YCAT, YKIND)};
+ if constexpr (resultType) {
return DoMatmul<IS_ALLOCATING, resultType->first, resultType->second,
CppTypeFor<XCAT, XKIND>, CppTypeFor<YCAT, YKIND>>(
result, x, y, terminator);
More information about the llvm-commits
mailing list