From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E5F623814FD7; Mon, 30 May 2022 09:14:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5F623814FD7 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/53533] [10/11/12/13 regression] vectorization causes loop unrolling test slowdown as measured by Adobe's C++Benchmark Date: Mon, 30 May 2022 09:14:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 4.7.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 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, 30 May 2022 09:14:45 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53533 --- Comment #48 from rguenther at suse dot de --- On Mon, 30 May 2022, crazylht at gmail dot com wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53533 >=20 > --- Comment #47 from Hongtao.liu --- >=20 > >=20 > > The issue is that the re-association pass doesn't handle operations > > with undefined overflow behavior, we do have duplicate bugreports > > for this. > >=20 >=20 > I saw below in match.pd >=20 > 478/* Combine successive multiplications. Similar to above, but handling > 479 overflow is different. */ > 480(simplify > 481 (mult (mult @0 INTEGER_CST@1) INTEGER_CST@2) > 482 (with { > 483 wi::overflow_type overflow; > 484 wide_int mul =3D wi::mul (wi::to_wide (@1), wi::to_wide (@2), > 485 TYPE_SIGN (type), &overflow); > 486 } > 487 /* Skip folding on overflow: the only special case is @1 * @2 =3D=3D > -INT_MIN, > 488 otherwise undefined overflow implies that @0 must be zero. */ > 489 (if (!overflow || TYPE_OVERFLOW_WRAPS (type)) > 490 (mult @0 { wide_int_to_tree (type, mul); })))) >=20 > Can it be extend to (mult (plus_minus (mult @0 INTEGER_CST@1) INTEGER_CST= @3) > INTEGER_CST@2), so at least we can handle it under -fwrapv? With -fwrapv the reassoc pass might do this already (not sure with mixing multiplication and addition, you'd have to try). But sure, we could add a pattern for the above (with appropriate single-use handling).=