From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2694138582BF; Mon, 8 Aug 2022 07:12:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2694138582BF From: "malat at debian dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106322] tree-vectorize: Wrong code at O2 level (-fno-tree-vectorize is working) Date: Mon, 08 Aug 2022 07:12:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: malat at debian dot org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Aug 2022 07:12:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106322 --- Comment #16 from Mathieu Malaterre --- Simplified version: % cat demo.cc #include "hwy/highway.h" #include "hwy/tests/test_util-inl.h" struct TestMulHigh { template void operator()(T /*unused*/, D d) { const size_t N =3D 2; hwy::AlignedFreeUniquePtr in_lanes =3D hwy::AllocateAligned(N); uint16_t expected_lanes[2]; for (size_t i =3D 0; i < N; ++i) { in_lanes[i] =3D T(hwy::LimitsMax() >> i); } expected_lanes[0] =3D 65534 ; expected_lanes[1] =3D 16383 ; hwy::N_EMU128::Vec128 v =3D Load(d, in_lanes.get()); HWY_ASSERT_VEC_EQ(d, in_lanes.get(), v); hwy::N_EMU128::Vec128 actual =3D MulHigh(v, v); HWY_ASSERT_VEC_EQ(d, expected_lanes, actual); } }; int main() { TestMulHigh()(uint16_t(), hwy::N_EMU128::FixedTag()); } Working: % g++ -O2 -fno-tree-vectorize -o demo demo.cc -lhwy -lhwy_test Not working: % g++ -O2 -o demo demo.cc -lhwy -lhwy_test With: % apt-cache policy libhwy-dev libhwy-dev: Installed: 1.0.0-5 Candidate: 1.0.0-5 Version table: *** 1.0.0-5 500 500 http://deb.debian.org/debian sid/main i386 Packages 100 /var/lib/dpkg/status=