From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id B53883938C2D; Wed, 3 Feb 2021 15:51:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B53883938C2D MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-7080] libstdc++: Improve test codegen for interpreting assembly X-Act-Checkin: gcc X-Git-Author: Matthias Kretz X-Git-Refname: refs/heads/master X-Git-Oldrev: 8f7ad986515580265f4315a6036ef3b49eb6be47 X-Git-Newrev: af60e4bd4b69f39173a8347aa2dcdaa40227ec67 Message-Id: <20210203155109.B53883938C2D@sourceware.org> Date: Wed, 3 Feb 2021 15:51:09 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Feb 2021 15:51:09 -0000 https://gcc.gnu.org/g:af60e4bd4b69f39173a8347aa2dcdaa40227ec67 commit r11-7080-gaf60e4bd4b69f39173a8347aa2dcdaa40227ec67 Author: Matthias Kretz Date: Wed Feb 3 15:49:30 2021 +0000 libstdc++: Improve test codegen for interpreting assembly In many failure cases it is helpful to inspect the instructions leading up to the test failure. After this change the location is easier to find and the branch after failure is easier to find. libstdc++-v3/ChangeLog: * testsuite/experimental/simd/tests/bits/verify.h (verify): Add instruction pointer data member. Ensure that the `if (m_failed)` branch is always inlined into the calling code. The body of the conditional can still be a function call. Move the get_ip call into the verify ctor to simplify the ctor calls. (COMPARE): Don't mention the use of all_of for reduction of a simd_mask. It only distracts from the real issue. Diff: --- .../experimental/simd/tests/bits/verify.h | 44 +++++++++++----------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h b/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h index 826cfc34b5f..82016c66802 100644 --- a/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h +++ b/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h @@ -60,6 +60,7 @@ template class verify { const bool m_failed = false; + size_t m_ip = 0; template () @@ -129,20 +130,21 @@ class verify public: template - verify(bool ok, size_t ip, const char* file, const int line, + [[gnu::always_inline]] + verify(bool ok, const char* file, const int line, const char* func, const char* cond, const Ts&... extra_info) - : m_failed(!ok) + : m_failed(!ok), m_ip(get_ip()) { if (m_failed) - { + [&] { __builtin_fprintf(stderr, "%s:%d: (%s):\nInstruction Pointer: %x\n" "Assertion '%s' failed.\n", - file, line, func, ip, cond); + file, line, func, m_ip, cond); (print(extra_info, int()), ...); - } + }(); } - ~verify() + [[gnu::always_inline]] ~verify() { if (m_failed) { @@ -152,26 +154,27 @@ public: } template + [[gnu::always_inline]] const verify& operator<<(const T& x) const { if (m_failed) - { - print(x, int()); - } + print(x, int()); return *this; } template + [[gnu::always_inline]] const verify& on_failure(const Ts&... xs) const { if (m_failed) - (print(xs, int()), ...); + [&] { (print(xs, int()), ...); }(); return *this; } - [[gnu::always_inline]] static inline size_t + [[gnu::always_inline]] static inline + size_t get_ip() { size_t _ip = 0; @@ -220,24 +223,21 @@ template #define COMPARE(_a, _b) \ [&](auto&& _aa, auto&& _bb) { \ - return verify(std::experimental::all_of(_aa == _bb), verify::get_ip(), \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, \ - "all_of(" #_a " == " #_b ")", #_a " = ", _aa, \ + return verify(std::experimental::all_of(_aa == _bb), __FILE__, __LINE__, \ + __PRETTY_FUNCTION__, #_a " == " #_b, #_a " = ", _aa, \ "\n" #_b " = ", _bb); \ }(force_fp_truncation(_a), force_fp_truncation(_b)) #else #define COMPARE(_a, _b) \ [&](auto&& _aa, auto&& _bb) { \ - return verify(std::experimental::all_of(_aa == _bb), verify::get_ip(), \ - __FILE__, __LINE__, __PRETTY_FUNCTION__, \ - "all_of(" #_a " == " #_b ")", #_a " = ", _aa, \ + return verify(std::experimental::all_of(_aa == _bb), __FILE__, __LINE__, \ + __PRETTY_FUNCTION__, #_a " == " #_b, #_a " = ", _aa, \ "\n" #_b " = ", _bb); \ }((_a), (_b)) #endif #define VERIFY(_test) \ - verify(_test, verify::get_ip(), __FILE__, __LINE__, __PRETTY_FUNCTION__, \ - #_test) + verify(_test, __FILE__, __LINE__, __PRETTY_FUNCTION__, #_test) // ulp_distance_signed can raise FP exceptions and thus must be conditionally // executed @@ -245,9 +245,9 @@ template [&](auto&& _aa, auto&& _bb) { \ const bool success = std::experimental::all_of( \ vir::test::ulp_distance(_aa, _bb) <= (_allowed_distance)); \ - return verify(success, verify::get_ip(), __FILE__, __LINE__, \ - __PRETTY_FUNCTION__, "all_of(" #_a " ~~ " #_b ")", \ - #_a " = ", _aa, "\n" #_b " = ", _bb, "\ndistance = ", \ + return verify(success, __FILE__, __LINE__, __PRETTY_FUNCTION__, \ + #_a " ~~ " #_b, #_a " = ", _aa, "\n" #_b " = ", _bb, \ + "\ndistance = ", \ success ? 0 : vir::test::ulp_distance_signed(_aa, _bb)); \ }((_a), (_b))