From c734252ab9d76d6f6c54dee35fd149db8484dc9d Mon Sep 17 00:00:00 2001 From: lloda Date: Tue, 28 Nov 2023 12:12:26 +0100 Subject: [PATCH] Another workaround for 'forwarding' issue Doesn't seem to be a forwarding issue at all, but rather gcc thinking that rank can be 0 in places where it can't. gcc11 doesn't flag these, but also fails to optimize as bench-at:Small/Small as much. * ra/expr.hh (Match): Revert to no fwd. * ra/big.hh (CellBig), ra/small.hh (CellSmall): Remove diagnostic guards around len(). * ra/ply.hh (ply_ravel): Move guards here, where the confusion happens. * ra/expr.hh (Match::check): Idem. --- ra/big.hh | 3 --- ra/expr.hh | 5 ++++- ra/ply.hh | 3 +++ ra/small.hh | 3 --- test/bug83.cc | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ra/big.hh b/ra/big.hh index 213c28ff..69b138d9 100644 --- a/ra/big.hh +++ b/ra/big.hh @@ -42,10 +42,7 @@ struct CellBig consteval static rank_t rank() requires (ANY!=framer) { return framer; } constexpr rank_t rank() const requires (ANY==framer) { return rank_frame(std::ssize(dimv), dspec); } -#pragma GCC diagnostic push // gcc 12.2 and 13.2 with RA_DO_CHECK=0 and -fno-sanitize=all -#pragma GCC diagnostic warning "-Warray-bounds" constexpr dim_t len(int k) const { return dimv[k].len; } // len(0<=k, mp::int_list> return false; } else if constexpr (1==c) { for (int k=0; k(t)) && ls!=choose_len(std::get(t).len(k), ls)) || ...)) { RA_CHECK(!checkp, "Mismatch on axis ", k, " [", (std::array { std::get(t).len(k) ... }), "]."); return false; @@ -357,7 +360,7 @@ struct Match, mp::int_list> } constexpr - Match(P ... p_): t(RA_FWD(p_) ...) // [ra1] + Match(P ... p_): t(p_ ...) // [ra1] { // TODO Maybe on ply, would make checkp unnecessary, make agree_xxx() unnecessary. if constexpr (checkp && !(has_len

|| ...)) { diff --git a/ra/ply.hh b/ra/ply.hh index 313ab5e8..f3081315 100644 --- a/ra/ply.hh +++ b/ra/ply.hh @@ -160,6 +160,8 @@ ply_ravel(A && a, Early && early = Nop {}) // find outermost compact dim. rank_t * ocd = order; dim_t ss = a.len(*ocd); +#pragma GCC diagnostic push // gcc 12.2 and 13.2 with RA_DO_CHECK=0 and -fno-sanitize=all +#pragma GCC diagnostic warning "-Warray-bounds" for (--rank, ++ocd; rank>0 && a.keep_step(ss, order[0], *ocd); --rank, ++ocd) { ss *= a.len(*ocd); } @@ -203,6 +205,7 @@ ply_ravel(A && a, Early && early = Nop {}) } } } +#pragma GCC diagnostic pop } diff --git a/ra/small.hh b/ra/small.hh index 7ac84dde..2fa36109 100644 --- a/ra/small.hh +++ b/ra/small.hh @@ -265,10 +265,7 @@ struct CellSmall ctype c; consteval static rank_t rank() { return framer; } -#pragma GCC diagnostic push // gcc 13.2 -#pragma GCC diagnostic warning "-Warray-bounds" constexpr static dim_t len(int k) { return dimv[k].len; } // len(0<=k A({4, 4}, ra::_1*10 + ra::_0 + 3); - A = ra::expr([](auto && a) { return a(0, 0); }, ra::iter<2>(A)); + A = ra::expr([](auto && a) { return a(0, 0); }, ra::iter<2>(A)); // [ra1] tr.info("A ", A).test_eq(3, A); return tr.summary(); }