From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 919C13858D32; Mon, 15 Aug 2022 09:06:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 919C13858D32 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106617] [13 Regression] gcc is very slow at ternary expressions, Date: Mon, 15 Aug 2022 09:06:51 +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: compile-time-hog, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 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 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, 15 Aug 2022 09:06:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106617 --- Comment #8 from Richard Biener --- We don't fold because case COMPOUND_EXPR: /* When pedantic, a compound expression can be neither an lvalue nor an integer constant expression. */ if (TREE_SIDE_EFFECTS (arg0) || TREE_CONSTANT (arg1)) return NULL_TREE; /* Don't let (0, 0) be null pointer constant. */ tem =3D integer_zerop (arg1) ? build1_loc (loc, NOP_EXPR, type, arg1) : fold_convert_loc (loc, type, arg1); return tem; where we chicken out because of the fear of early folding. At least the C frontend should get this correct now. Ideally the above would just return arg1 if !TREE_SIDE_EFFECTS (arg0). OTOH it's really sth for language specific folding. Of course the bug then would be still present when replacing (0, 0) with something non-constant.=