From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B455B3858405; Wed, 23 Mar 2022 13:50:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B455B3858405 From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105032] Compiling inline ASM x86 causing GCC stuck in an endless loop with 100% CPU usage Date: Wed, 23 Mar 2022 13:50:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: compile-time-hog, inline-asm, ra X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub 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: --- 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: Wed, 23 Mar 2022 13:50:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105032 --- Comment #7 from Jakub Jelinek --- Consider e.g. void bar (int *); int foo (int *a, int *b, int *c, int *d) { for (int i =3D 0; i < 1024; i++) a[i] =3D a[i] * b[i] + (c[i] - d[i]); bar (a); return 42; } with -m32 -O3 -mavx -mstackrealign. It needs to dynamically realign the stack because user asked for it (so tha= t it can use 256-bit aligned stack slots and callers don't guarantee that alignment), so it needs a frame pointer (%ebp), stack pointer (%esp) and DR= AP (%ecx in this case). Especially if you e.g. also use VLAs or alloca in the function. %ebp based addressing is for the automatic vars in the function in its stack frame, stack pointer can be variable offset from it used for outgoing argum= ents to function calls and push/pop or for alloca/VLAs and DRAP is used to access function arguments which aren't at fixed offset from the frame pointer eith= er. Anyway, with the "b" etc. constraints (which is a good idea to use on x86 w= hen it has single register constraints for those but can't be used on other arc= hes which do not have such constraints) you just trigger slightly different pat= h in the RA, but the problem remains roughly the same, you force use of 6 regist= ers as input plus one memory address and esp is a stack pointer and ebp could b= e a frame pointer and it is a question if you don't need another register for t= he address of the memory input. A way to free one input would be to store 2 arguments into an array and use= the whole array as one memory input and only inside of the inline asm load it i= nto the right registers.=