From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B4F273858D28; Thu, 26 Jan 2023 11:27:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B4F273858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1674732470; bh=+9efky2+pqu1IH9zL8tNw4NxeJKrh2dZtihst92KJ1o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W2Um3Q/tVmVPZBOgoDE6MK+8HRsJJtIC3VQaEMMwsaQbRp1+J1v978Q1/g0NWJ+iK UzySFQustzJZCNSWLmiqga3rpCnaUE22mJKOv+MAl5Qb5R4ZyZs1qMP1sh2MIcbmdH WxLriD1E0kUZdJrx06M8j9DI0EHZcGTH0nMZcMrE= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108540] [13 Regression] Frange miscompilation of ruby since r13-3261 Date: Thu, 26 Jan 2023 11:27:49 +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: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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=3D108540 --- Comment #2 from Jakub Jelinek --- This goes wrong during thread1 pass I think. Before that we have in the IL early exits for x !=3D 42, d NAN or d +-INF, = and then: [local count: 96926676]: if (d_16(D) =3D=3D 0.0) goto ; [50.00%] else goto ; [50.00%] [local count: 48463338]: _2 =3D __builtin_signbit (d_16(D)); if (_2 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 72695007]: [local count: 164282501]: # RANGE [frange] double [-0.0 (-0x0.0p+0), 1.79769313486231570814527423731704356798070567525844996599e+308 (0x0.fffffffffffff8p+1024)] # d_7 =3D PHI # RANGE [irange] char [0, 0][45, 45] NONZERO 0x2d # sign_10 =3D PHI <45(5), 45(7), 0(8)> _3 =3D ch_18(D) =3D=3D 97; _4 =3D ch_18(D) =3D=3D 65; _5 =3D _3 | _4; if (_5 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 82141250]: _13 =3D VIEW_CONVERT_EXPR(d_7); _24 =3D _13 < 0; # RANGE [irange] int [0, 1] NONZERO 0x1 _25 =3D (int) _24; if (d_7 =3D=3D 0.0) goto ; [50.00%] else goto ; [50.00%] [local count: 41070625]: [local count: 82141250]: # PT =3D # cp_8 =3D PHI <"WRONG"(11), "ZERO"(10)> (#c1 testcase at -O2 on x86_64-linux in sra dump). The path through the IL= on arguments the function is called with is d_16(D) =3D=3D 0.0, __builtin_signbit (d_16(D)) is non-zero and so d_7 is -= 0.0, sign_10 45, then _5 is non-zero, d_7 =3D=3D 0.0 is again true and so cp_8 is "ZERO". But in thread1 this changes: [local count: 96926676]: if (d_16(D) =3D=3D 0.0) goto ; [50.00%] else goto ; [50.00%] [local count: 48463338]: _2 =3D __builtin_signbit (d_16(D)); if (_2 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 24231669]: # RANGE [frange] double [-0.0 (-0x0.0p+0), 1.79769313486231570814527423731704356798070567525844996599e+308 (0x0.fffffffffffff8p+1024)] # d_11 =3D PHI <-0.0(7)> # RANGE [irange] char [0, 0][45, 45] NONZERO 0x2d # sign_26 =3D PHI <45(7)> _27 =3D ch_18(D) =3D=3D 97; _28 =3D ch_18(D) =3D=3D 65; _29 =3D _27 | _28; if (_29 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 12115835]: _30 =3D VIEW_CONVERT_EXPR(d_11); _31 =3D _30 < 0; # RANGE [irange] int [0, 1] NONZERO 0x1 _32 =3D (int) _31; goto ; [100.00%] ... [local count: 41070625]: # RANGE [irange] char [0, 0][45, 45] NONZERO 0x2d # sign_33 =3D PHI # RANGE [irange] int [0, 1] NONZERO 0x1 # _35 =3D PHI <_25(11), _32(9)> [local count: 82141250]: # PT =3D # cp_8 =3D PHI <"WRONG"(12), "ZERO"(11)> Now the path through for the arguments is again d_16(D) =3D=3D 0.0, signbit non-zero, d_11 is correctly -0.0 but this is in a threaded block, _29 is non-zero, but we come into bb 13 from bb 12 and so cp_8 is "WRONG" rather t= han "ZERO". Aldy, can you please have a look?=