From 839a34be9b5a1e994df71fff95e775f5199ab231 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 8 May 2023 15:47:50 +0200 Subject: [PATCH] Weight kernel for multigrid: Simplify aliasing analysis for compiler --- include/deal.II/matrix_free/tensor_product_kernels.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/deal.II/matrix_free/tensor_product_kernels.h b/include/deal.II/matrix_free/tensor_product_kernels.h index 99b69eb97f..38c44f4762 100644 --- a/include/deal.II/matrix_free/tensor_product_kernels.h +++ b/include/deal.II/matrix_free/tensor_product_kernels.h @@ -3693,8 +3693,9 @@ namespace internal data[0] *= weights[shift]; // loop bound as int avoids compiler warnings in case n_points_1d // == 1 (polynomial degree 0) + const Number weight = weights[shift + 1]; for (int i = 1; i < n_points_1d - 1; ++i) - data[i] *= weights[shift + 1]; + data[i] *= weight; data[n_points_1d - 1] *= weights[shift + 2]; data += n_points_1d; } @@ -3735,12 +3736,14 @@ namespace internal const unsigned int shift = 9 * compressed_index[k] + 3 * compressed_index[j]; - unsigned int c = 0; + unsigned int c = 0; + const Number weight1 = weights[shift]; for (int i = 0; i < n_inside_1d; ++i) - data[c++] *= weights[shift]; + data[c++] *= weight1; data[c++] *= weights[shift + 1]; + const Number weight2 = weights[shift + 2]; for (int i = 0; i < n_inside_1d; ++i) - data[c++] *= weights[shift + 2]; + data[c++] *= weight2; data += n_points_1d; } } -- 2.39.5