From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 178633858C52; Fri, 23 Sep 2022 13:57:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 178633858C52 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663941443; bh=NUwrH6iO8zkafOEmVnXjQevZGPHyc81r7G/Hm7ar6Jk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TndmRMOcEyspB9yGbohRwYvTbCZlGM/VpLva9LkOoUweJzfE7UVlIDhNHCCoEzBRY Lz96vRRoIkfFJcKZI7EEuQGk6UCCdUeictGMnDAYswYFxXQxcEurDPAduLHEPa4Vct RMfeQhNI0pimhzjiE8uLpzI5H/X/8uoy6KioV+sM= From: "aldyh at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107009] [13 Regression] massive unnecessary code blowup in vectorizer Date: Fri, 23 Sep 2022 13:57:17 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: aldyh at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.0 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107009 --- Comment #4 from Aldy Hernandez --- (In reply to Richard Biener from comment #3) > # RANGE [irange] size_t [1, +INF] > size_t n_12(D) =3D n; >=20 > the nonzero bits info on 'n' is gone. DOM2 used to produce that and > CCP3 elides the __builtin_unreachable () but if DOM2 is disabled that > doesn't produce the nonzero bits. >=20 > DOM2 from trunk no longer sets nonzero bits. CCP doesn't do any > conditional non-zero bits (or constant equivalence) propagation. Indeed, there is a missing nonzero mask on n_12(D). Thanks for the analysi= s, Richi. It saved me a ton of work. This is the problematic BB, where the 2->3 edge is unreachable: [local count: 118111600]: _1 =3D n_12(D) & 7; if (_1 !=3D 0) goto ; [0.00%] else goto ; [100.00%] _1 : [irange] long unsigned int [0, 0] 2->3 (T) _1 : [irange] UNDEFINED 2->3 (T) n_12(D) : [irange] UNDEFINED 2->4 (F) _1 : [irange] long unsigned int [0, 0] 2->4 (F) n_12(D) : [irange] size_t [1, 18446744073709551608] <-- BOO HISS!!!! Notice there is no nonzero mask on n_12(D) in the 2->4 edge which is unreachable. So this is actually our fault, not because of this patch, but because we di= dn't track nonzero bits back then. I keep saying, this patch is a red herring := -P. However, we do track nonzero bits now, and the testcase still fails so... The culprit is operator_bitwise_and::op1_range() which is not setting the nonzero mask. This should be quite easy to fix. What we're trying to solv= e is n_12 on the 2->4 edge: _1 =3D n_12(D) & 7; which _1 =3D 0 because we're talking about the 2->4 edge: 0 =3D n_12(D) & 7; So the mask should be everything but the lower 3 bits, 0xffff...f8 if my ma= th is correct.=