[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / views / mdspan / layout_right / stride.pass.cpp
blob9a27859afb9592a9d6a922b32ec99e7da9c5150c
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // <mdspan>
13 // constexpr index_type stride(rank_type i) const noexcept;
15 // Constraints: extents_type::rank() > 0 is true.
17 // Preconditions: i < extents_type::rank() is true.
19 // Returns: extents().rev-prod-of-extents(i).
21 #include <mdspan>
22 #include <cassert>
23 #include <array>
24 #include <cstdint>
25 #include <cstdio>
26 #include "test_macros.h"
28 template <class E, class... Args>
29 constexpr void test_stride(std::array<typename E::index_type, E::rank()> strides, Args... args) {
30 using M = std::layout_right::mapping<E>;
31 M m(E(args...));
33 ASSERT_NOEXCEPT(m.stride(0));
34 for (size_t r = 0; r < E::rank(); r++)
35 assert(strides[r] == m.stride(r));
38 constexpr bool test() {
39 constexpr size_t D = std::dynamic_extent;
40 test_stride<std::extents<unsigned, D>>(std::array<unsigned, 1>{1}, 7);
41 test_stride<std::extents<unsigned, 7>>(std::array<unsigned, 1>{1});
42 test_stride<std::extents<unsigned, 7, 8>>(std::array<unsigned, 2>{8, 1});
43 test_stride<std::extents<int64_t, D, 8, D, D>>(std::array<int64_t, 4>{720, 90, 10, 1}, 7, 9, 10);
44 return true;
47 int main(int, char**) {
48 test();
49 static_assert(test());
50 return 0;