From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 43AFC3858C27; Thu, 17 Aug 2023 14:52:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43AFC3858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1692283949; bh=vgjMeI6IjY0xbTUdKADWwBa2jo4E9/Av3s2Kq4A9VCQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Mc1NjuauyZp+4WCoU+P4D57c3LtQ1pwXD7P2G+pVegCzRVAEBIXMO4EdaCQm1k2J1 SEbg38tBz0B41mvg/we9whj7M0t0ycY1UKSrH+yLJ1rbe5ebMasnSzkLQqg3yOVFzf Na9Q8z2BbOTGVohQYZnkpLyN4vlx9nOtYyAQnpGc= From: "hubicka at ucw dot cz" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110628] [14 regression] gcc.dg/tree-ssa/update-threading.c fails after r14-2383-g768f00e3e84123 Date: Thu, 17 Aug 2023 14:52:27 +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: 14.0 X-Bugzilla-Keywords: testsuite-fail X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at ucw dot cz X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 14.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=3D110628 --- Comment #6 from Jan Hubicka --- The mismatch happens on: void foo (unsigned int x) { if (x !=3D 0x800 && x !=3D 0x810) abort (); } It is bug in reassoc turning: void foo (unsigned int x) {=20=20 ;; basic block 2, loop depth 0, count 1073741824 (estimated locally, freq 1.0000), maybe hot ;; prev block 0, next block 3, flags: (NEW, REACHABLE, VISITED) ;; pred: ENTRY [always] count:1073741824 (estimated locally, freq 1.0000) (FALLTHRU,EXECUTABLE) if (x_1(D) !=3D 2048) goto ; [66.00%] else goto ; [34.00%] ;; succ: 3 [66.0% (guessed)] count:708669600 (estimated locally, = freq 0.6600) (TRUE_VALUE,EXECUTABLE) ;; 5 [34.0% (guessed)] count:365072224 (estimated locally, = freq 0.3400) (FALSE_VALUE,EXECUTABLE) ;; basic block 3, loop depth 0, count 708669600 (estimated locally, freq 0.6600), maybe hot ;; prev block 2, next block 4, flags: (NEW, REACHABLE, VISITED) ;; pred: 2 [66.0% (guessed)] count:708669600 (estimated locally, = freq 0.6600) (TRUE_VALUE,EXECUTABLE) if (x_1(D) !=3D 2064) goto ; [0.00%] else goto ; [100.00%]=20 ;; succ: 4 [never] count:0 (precise, freq 0.0000) (TRUE_VALUE,EXECUTABLE) ;; 5 [always] count:708669600 (estimated locally, freq 0.66= 00) (FALSE_VALUE,EXECUTABLE) ;; basic block 4, loop depth 0, count 0 (precise, freq 0.0000), probably never executed ;; prev block 3, next block 5, flags: (NEW, REACHABLE, VISITED) ;; pred: 3 [never] count:0 (precise, freq 0.0000) (TRUE_VALUE,EXECUTABLE) abort (); ;; succ:=20=20=20=20=20=20=20 to: void foo (unsigned int x) { unsigned int _4; _Bool _5; ;; basic block 2, loop depth 0, count 1073741824 (estimated locally, freq 1.0000), maybe hot ;; prev block 0, next block 3, flags: (NEW, REACHABLE, VISITED) ;; pred: ENTRY [always] count:1073741824 (estimated locally, freq 1.0000) (FALLTHRU,EXECUTABLE) _4 =3D x_1(D) & 4294967279; _5 =3D _4 !=3D 2048; if (_5 !=3D 0) goto ; [66.00%] else goto ; [34.00%] ;; succ: 3 [66.0% (guessed)] count:708669600 (estimated locally, = freq 0.6600) (TRUE_VALUE,EXECUTABLE) ;; 4 [34.0% (guessed)] count:365072224 (estimated locally, = freq 0.3400) (FALSE_VALUE,EXECUTABLE) ;; basic block 3, loop depth 0, count 0 (precise, freq 0.0000), probably never executed ;; Invalid sum of incoming counts 708669600 (estimated locally, freq 0.66= 00), should be 0 (precise, freq 0.0000) ;; prev block 2, next block 4, flags: (NEW, REACHABLE, VISITED) ;; pred: 2 [66.0% (guessed)] count:708669600 (estimated locally, = freq 0.6600) (TRUE_VALUE,EXECUTABLE) abort (); ;; succ: ;; basic block 4, loop depth 0, count 1073741824 (estimated locally, freq 1.0000), maybe hot ;; Invalid sum of incoming counts 365072224 (estimated locally, freq 0.34= 00), should be 1073741824 (estimated locally, freq 1.0000) ;; prev block 3, next block 1, flags: (NEW, REACHABLE, VISITED) ;; pred: 2 [34.0% (guessed)] count:365072224 (estimated locally, = freq 0.3400) (FALSE_VALUE,EXECUTABLE) return; So it combines two conditionals together but does not update the outgoing probabilitis of the conditional. On x86-64 we have already in cfg dump: _1 =3D x !=3D 2048; _2 =3D x !=3D 2064; _3 =3D _1 & _2; if (_3 !=3D 0) goto ; [INV] else I wonder why optimization diverges here?=