From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4D6733858C54; Thu, 14 Apr 2022 09:00:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4D6733858C54 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/105034] [10/11/12 regression]Suboptimal codegen for min/max with -Os Date: Thu, 14 Apr 2022 09:00:08 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 10.4 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: Thu, 14 Apr 2022 09:00:08 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105034 --- Comment #4 from Richard Biener --- Example that we don't transform but could: typedef int v4si __attribute__((vector_size(16))); #define min(a,b) ((a)<(b)?(a):(b)) v4si foo (v4si a, v4si b) { a[0] =3D min (a[0], b[0]); return a; } here the scalar code is movd %xmm0, %edx movd %xmm1, %eax cmpl %edx, %eax cmovg %edx, %eax pinsrd $0, %eax, %xmm0 where we could use sth like movq %xmm0, %xmm2 minpd %xmm2, %xmm1 a testcase variant could return the scalar minimum. For both cases it's likely a win even for -Os.=