libstdc++: Simplify calculation of expected value in simd test

Message ID 10530000.NyiUUSuA9g@minbar
State Accepted
Headers
Series libstdc++: Simplify calculation of expected value in simd test |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Matthias Kretz May 26, 2023, 11:09 a.m. UTC
  OK for master and all backports (after 11.4 is done)?

tested on powerpc64le-linux-gnu

----------- 8< ------------

This avoids a failure on PR109964.

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	* testsuite/experimental/simd/tests/integer_operators.cc:
	Compute expected value differently to avoid getting turned into
	a vector shift.
---
 .../experimental/simd/tests/integer_operators.cc         | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)


--
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 stdₓ::simd
──────────────────────────────────────────────────────────────────────────
  

Comments

Jonathan Wakely May 26, 2023, 3:45 p.m. UTC | #1
On Fri, 26 May 2023 at 12:09, Matthias Kretz via Libstdc++ <
libstdc++@gcc.gnu.org> wrote:

> OK for master and all backports (after 11.4 is done)?
>

OK



>
> tested on powerpc64le-linux-gnu
>
> ----------- 8< ------------
>
> This avoids a failure on PR109964.
>
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
>
> libstdc++-v3/ChangeLog:
>
>         * testsuite/experimental/simd/tests/integer_operators.cc:
>         Compute expected value differently to avoid getting turned into
>         a vector shift.
> ---
>  .../experimental/simd/tests/integer_operators.cc         | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
>
> --
> ──────────────────────────────────────────────────────────────────────────
>  Dr. Matthias Kretz                           https://mattkretz.github.io
>  GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
>  stdₓ::simd
> ──────────────────────────────────────────────────────────────────────────
  

Patch

diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/integer_operators.cc b/libstdc++-v3/testsuite/experimental/simd/tests/integer_operators.cc
index 7a2bc085e49..08ad49ca710 100644
--- a/libstdc++-v3/testsuite/experimental/simd/tests/integer_operators.cc
+++ b/libstdc++-v3/testsuite/experimental/simd/tests/integer_operators.cc
@@ -179,11 +179,10 @@  for (int s = 1; s < nbits; ++s)
 	  for (int j = 0; j < 100; ++j)
 	    {
 	      const V seq([&](auto i) -> T { return (j + i) % n_promo_bits; });
-	      COMPARE(V(1) >> seq, V([&](auto i) { return T(T(1) >> seq[i]); }))
-		<< "seq = " << seq;
-	      COMPARE(make_value_unknown(V(1)) >> make_value_unknown(seq),
-		V([&](auto i) { return T(T(1) >> seq[i]); }))
-		<< "seq = " << seq;
+	      const V expect([&](auto i) { return seq[i] == 0 ? T(1) : T(0); });
+	      COMPARE(V(1) >> seq, expect) << "\nseq = " << seq;
+	      COMPARE(make_value_unknown(V(1)) >> make_value_unknown(seq), expect)
+		<< "\nseq = " << seq;
 	    }
 	  for_constexpr<int, 0, n_promo_bits - 1>([](auto shift_ic) {
 	    constexpr int shift = shift_ic;