http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60206
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> --- On Fri, 14 Feb 2014, wmi at google dot com wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60206 > > Bug ID: 60206 > Summary: IVOPT has no idea of inline asm > Product: gcc > Version: 4.9.0 > Status: UNCONFIRMED > Severity: normal > Priority: P3 > Component: tree-optimization > Assignee: unassigned at gcc dot gnu.org > Reporter: wmi at google dot com > CC: rguenth at gcc dot gnu.org, shenhan at google dot com > Host: i386 > Target: i386 > > Created attachment 32141 > --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32141&action=edit > Testcase > > This bug is found in google branch but I think the same problem also exists on > trunk (but not exposed). > > For the testcase 1.c attached (1.c is extracted from libgcc/soft-fp/divtf3.c), > use trunk compiler gcc-r202164 (Target: x86_64-unknown-linux-gnu) + the patch > r204497 could expose the problem. > > The command: > gcc -v -O2 -fno-omit-frame-pointer -fpic -c -S -m32 1.c > > The error: > ./1.c: In function ‘__divtf3’: > ./1.c:64:1194: error: ‘asm’ operand has impossible constraints > > The inline asm in error message is as follow: > do { > __asm__ ( > "sub{l} {%11,%3|%3,%11}\n\t" > "sbb{l} {%9,%2|%2,%9}\n\t" > "sbb{l} {%7,%1|%1,%7}\n\t" > "sbb{l} {%5,%0|%0,%5}" > : "=r" ((USItype) (A_f[3])), "=&r" ((USItype) (A_f[2])), "=&r" ((USItype) > (A_f[1])), "=&r" ((USItype) (A_f[0])) : "0" ((USItype) (B_f[2])), "g" > ((USItype) (A_f[2])), "1" ((USItype) (B_f[1])), "g" ((USItype) (A_f[1])), "2" > ((USItype) (B_f[0])), "g" ((USItype) (A_f[0])), "3" ((USItype) (0)), "g" > ((USItype) (_n_f[_i]))); > } while () > > Because -fno-omit-frame-pointer is turned on and the command line uses -fpic, > there are only 5 registers for register allocation. > > Before IVOPT, > %0, %1, %2, %3 require 4 registers. The index variable i of _n_f[_i] requires > another register. So 5 registers are used up here. > > After IVOPT, MEM reference _n_f[_i] is converted to MEM[base: _874, index: > ivtmp.22_821, offset: 0B]. base and index require 2 registers, Now 6 registers > are required, so LRA cannot find enough registers to allocate. > > trunk compiler doesn't expose the problem because of patch r202165. With patch > r202165, IVOPT doesn't change _n_f[_i] in inline asm above. But it just hided > the problem. > > Should IVOPT care about the constraints in inline-asm and restrict its > optimization in some case? It's true that ASMs are not in any way special cased - it may be worth trying if distinguishing address-uses and other uses may be worth it. It's only a cost thing, of course. In general find_interesting_uses_stmt may need some modernization.