From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C3F3E3858C78; Fri, 12 May 2023 13:23:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C3F3E3858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683897830; bh=NiShLHd8PFpRx3piAOiHE/TG0kmVusxGGrl46xBmscg=; h=From:To:Subject:Date:From; b=jwUBi+K8r6ndtfdvlXp7SqG/71dueOi+Wzsq4Qu+THOCa+4nr1xbOVaADeTXFM3x5 q3zfRsy6b+zGFk+tzAIbpW0jzBkq3mHvnLY87vXdL3+36UnEbbpgnPyCsaeR3fa+Ih 3602lDvbnr83m6q5UqbPqA3w8GwEeRAKjU0i46A0= From: "antoshkka at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109829] New: Optimizing __builtin_signbit(x) ? -x : x or abs for FP Date: Fri, 12 May 2023 13:23:50 +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: 13.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: antoshkka at gmail dot com 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=3D109829 Bug ID: 109829 Summary: Optimizing __builtin_signbit(x) ? -x : x or abs for FP Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: antoshkka at gmail dot com Target Milestone: --- Consider the following 2 functions: __float128 abs1(__float128 x) { return __builtin_fabsf128(x); } __float128 abs2(__float128 x) { return __builtin_signbit(x) ? -x : x; } They should provide the same results, however the codegen is different: abs1(__float128): pand xmm0, XMMWORD PTR .LC0[rip] ret abs2(__float128): movmskps eax, xmm0 test al, 8 je .L4 pxor xmm0, XMMWORD PTR .LC1[rip] .L4: ret Looks like match.pd miss the __builtin_signbit(x) ? -x : x -> __builtin_fabs*(x) pattern. Playground: https://godbolt.org/z/bsxeozGqv=