From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 08DA93858CDB; Tue, 16 Jan 2024 00:23:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 08DA93858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1705364633; bh=ggjgEtVXIpy9YpaAD+xodA7shaWeV0T5vRQDLgspdXE=; h=From:To:Subject:Date:From; b=HtwWR1qncEWDCrlqcKB9uWF8+o5a3cw8A+mhCLmzwB5NRXAiq7JM0vZ2XSbZWPTRC qpMtpcw3yPuNflQTkSOKoRj6smeXgLiQiT+LF1AP6UTocR2nAKXBHQYDK9W4YrnvZM VMIiFWZovGMhaAYqzGTInb0PYXUkz6aiz8JWOIQw= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113411] New: ABS*ABS can be simplified to ABS Date: Tue, 16 Jan 2024 00:23:52 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D113411 Bug ID: 113411 Summary: ABS*ABS can be simplified to ABS Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Take: ``` static inline int abs(int a) { signed b =3D a; if (a < 0) b =3D -b; return b; } int foo1(int a, int b) { return abs(a) * abs(b); } ``` foo1 can be simplified down to `abs(a*b)`. Note I think this is only valid= for signed overflowable types and not valid with -fwrapv (but I could be wrong). Maybe ok for real types with -ffast-math.=