public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/31386] New: wrong registers used in cmov instruction
@ 2007-03-28 21:35 ramiro at lisha dot ufsc dot br
2007-03-28 21:40 ` [Bug inline-asm/31386] " ramiro at lisha dot ufsc dot br
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: ramiro at lisha dot ufsc dot br @ 2007-03-28 21:35 UTC (permalink / raw)
To: gcc-bugs
This is reproduceable with gcc 4.0.0 and gcc SVN, but not with gcc 3.4.6.
I still don't really know what's the problem, but I think it may be that not
enough registers are available for output, and gcc is using the same register
for 2 different outputs.
gccs were built with:
--prefix=/usr --enable-languages=c --program-suffix=-{svn,4.0.0}
file was compiled with:
gcc-{svn,4.0.0} -v -save-temps -O3 -c regs.c
The corresponding inline asm that triggers the error is the following, when
used many times in a function inside many ifs:
asm volatile (
"cmpl %0, %3\n\t"
"cmovl %3, %0\n\t"
"cmovl %4, %1\n\t"
"cmovl %5, %2\n\t"
: "+r" (dmin), "+r" (dx), "+r" (dy)
: "r" (d), "r" (val1), "r" (val2)
);
The problem can be seen at the end of the assembly file:
# 47 "regs.c" 1
cmpl %edx, %esi
cmovl %esi, %edx
cmovl %edi, %eax
cmovl %ecx, %eax
# 0 "" 2
#NO_APP
movl %eax, %ebx
movl %eax, %edi
movl %eax, -36(%ebp)
movl %eax, -24(%ebp)
movl %edx, dmin
eax is used twice, both for dx and dy.
Test code minimized from motion_est.c from FFmpeg. Could be minimized further.
--
Summary: wrong registers used in cmov instruction
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: inline-asm
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ramiro at lisha dot ufsc dot br
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31386
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/31386] wrong registers used in cmov instruction
2007-03-28 21:35 [Bug inline-asm/31386] New: wrong registers used in cmov instruction ramiro at lisha dot ufsc dot br
@ 2007-03-28 21:40 ` ramiro at lisha dot ufsc dot br
2007-03-28 21:49 ` pinskia at gcc dot gnu dot org
2007-04-02 20:24 ` ramiro at lisha dot ufsc dot br
2 siblings, 0 replies; 5+ messages in thread
From: ramiro at lisha dot ufsc dot br @ 2007-03-28 21:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ramiro at lisha dot ufsc dot br 2007-03-28 22:39 -------
Created an attachment (id=13296)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=13296&action=view)
.c, .i and .s files
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31386
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/31386] wrong registers used in cmov instruction
2007-03-28 21:35 [Bug inline-asm/31386] New: wrong registers used in cmov instruction ramiro at lisha dot ufsc dot br
2007-03-28 21:40 ` [Bug inline-asm/31386] " ramiro at lisha dot ufsc dot br
@ 2007-03-28 21:49 ` pinskia at gcc dot gnu dot org
2007-04-02 20:24 ` ramiro at lisha dot ufsc dot br
2 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-03-28 21:49 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2007-03-28 22:49 -------
Actually I think the inline-asm should be:
#define CMOV_COMBO( val1, val2 ) \
asm volatile ( \
"cmpl %0, %3\n\t" \
"cmovl %3, %0\n\t" \
"cmovl %4, %1\n\t" \
"cmovl %5, %2\n\t" \
: "+&r" (dmin), "+&r" (dx), "+&r" (dy) \
: "r" (d), "r" (val1), "r" (val2) \
)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31386
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/31386] wrong registers used in cmov instruction
2007-03-28 21:35 [Bug inline-asm/31386] New: wrong registers used in cmov instruction ramiro at lisha dot ufsc dot br
2007-03-28 21:40 ` [Bug inline-asm/31386] " ramiro at lisha dot ufsc dot br
2007-03-28 21:49 ` pinskia at gcc dot gnu dot org
@ 2007-04-02 20:24 ` ramiro at lisha dot ufsc dot br
2 siblings, 0 replies; 5+ messages in thread
From: ramiro at lisha dot ufsc dot br @ 2007-04-02 20:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from ramiro at lisha dot ufsc dot br 2007-04-02 21:24 -------
Hello,
That and many other combinations fix the issue. Including changing the code
around the inline asm, or using different optimizations.
What seems wrong is that gcc uses the same register for 2 outputs. Maybe on
that specific register pressure it allocates the same register for 2 outputs.
Is gcc ever supposed to allow 2 output operands to use the same register?
Ramiro Polla
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31386
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug inline-asm/31386] wrong registers used in cmov instruction
[not found] <bug-31386-4@http.gcc.gnu.org/bugzilla/>
@ 2020-03-10 3:20 ` pinskia at gcc dot gnu.org
0 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2020-03-10 3:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=31386
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Invalid as mentioned, you need the early clobbers, otherwise GCC thinks the
output and input registers can be the same. In this case the output registers
which is held in operand 0 has to be different from operands 4 and 5.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-03-10 3:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-28 21:35 [Bug inline-asm/31386] New: wrong registers used in cmov instruction ramiro at lisha dot ufsc dot br
2007-03-28 21:40 ` [Bug inline-asm/31386] " ramiro at lisha dot ufsc dot br
2007-03-28 21:49 ` pinskia at gcc dot gnu dot org
2007-04-02 20:24 ` ramiro at lisha dot ufsc dot br
[not found] <bug-31386-4@http.gcc.gnu.org/bugzilla/>
2020-03-10 3:20 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).