[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #10 from NickParker at Eaton dot com 2011-09-04 21:22:30 UTC --- Richard, 'bogus' isnt a technical term I'm familiar with - I'm not entirely sure what you mean, however, I have found the problem with my ASM code. If you'll notice I am adding partial products to r4,r5,r6,r7 without them ever being initialised. What was missing was initialistion of the temporary result registers r4,r5,r6,r7 where I am generating my result. After adding these initialisatons, and also a few movw's for a few less cycles in a couple of places, the code now works correctly. Thanks for your input and sorry that I made a mess of reporting this bug, which was nothing to do with the compiler. Thanks, Nick.
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 Richard Guenther rguenth at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID --- Comment #9 from Richard Guenther rguenth at gcc dot gnu.org 2011-09-03 08:50:27 UTC --- bogus asm
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 Andrew Pinski pinskia at gcc dot gnu.org changed: What|Removed |Added Component|c |target Severity|major |normal
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #2 from Andrew Pinski pinskia at gcc dot gnu.org 2011-09-03 01:13:00 UTC --- I think your inline-asm is broken. You have: : =r (answer) : r (a_u4), r (b_u4) : r2,r3,r4,r5,r6,r7,r20 But you modify %1 and %2 which causes what you are seeing and GCC thinks your inline-asm does not modify those registers.
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #3 from NickParker at Eaton dot com 2011-09-03 01:28:57 UTC --- The final printed calculation result of MulU3U3S3() is wrong, because two of the four result registers are incorrect and have been overwritten. mulu3u3s3 : [ +0016777215 ] x [+000100 ] = [+0010502615 ] I am wondering if the CPU is running out of registers? Because I have found stepping through that the calcualtion is actually working correctly
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #4 from NickParker at Eaton dot com 2011-09-03 01:30:26 UTC --- Hi Andrew, Can you please explain what you mean by %1 and %2. Thanks.
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #5 from NickParker at Eaton dot com 2011-09-03 01:32:20 UTC --- Sorry. I pasted a broken version. Before. Code below works. uint32_t MulU3U3S3(uint32_t a_u4, uint32_t b_u4) { //uint32_t answer; asm volatile ( push r0 \n\t push r1 \n\t push r10 \n\t clr r10 \n\t // zero register // 0 byte shifts mul %A1,%A2 \n\t // a1a2 mov r2,r0\n\t mov r3,r1\n\t // 1 byte shifts mul %A1,%B2 \n\t add r3,r0\n\t adc r4,r1\n\t adc r5,r10 \n\t mul %A2,%B1 \n\t add r3,r0\n\t adc r4,r1\n\t adc r5,r10 \n\t // 2 byte shifts mul %A1,%C2 \n\t add r4,r0\n\t adc r5,r1\n\t adc r6,r10 \n\t mul %A2,%C1 \n\t add r4,r0\n\t adc r5,r1\n\t adc r6,r10 \n\t mul %B2,%B1 \n\t add r4,r0\n\t adc r5,r1\n\t adc r6,r10 \n\t // 3 byte shifts mul %B1,%C2 \n\t add r5,r0\n\t adc r6,r1\n\t adc r7,r10 \n\t mul %B2,%C1 \n\t add r5,r0\n\t adc r6,r1\n\t adc r7,r10 \n\t // 4 byte shifts mul %C2,%C1 \n\t add r6,r0\n\t adc r7,r1\n\t mov %A0,r5 \n\t mov %B0,r6 \n\t mov %C0,r7 \n\t clr %D0 \n\t //adc %G0,r20 \n\t pop r10 \n\t pop r1 \n\t pop r0 \n\t : =r (answer) : r (a_u4), r (b_u4) : r2,r3,r4,r5,r6,r7,r10 ); return (answer); }
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #6 from Andrew Pinski pinskia at gcc dot gnu.org 2011-09-03 01:38:44 UTC --- Oh the real issue is that the : r (a_u4), r (b_u4) Those two arguments could be in r0 or r1. Also the generated asm does not correspond to the source you gave as there is an extra push/pop r10.
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #7 from NickParker at Eaton dot com 2011-09-03 04:45:08 UTC --- Please ignore the r10/r20 guff I was experimenting. I later realised the muls3s3u3 code gives the right answer, the problem occurs later on somehow Nick.
[Bug target/50281] result registers are overwritten giving incorrect result
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50281 --- Comment #8 from NickParker at Eaton dot com 2011-09-03 04:46:45 UTC --- Please ignore the r10/r20 guff I was experimenting. I later realised the muls3s3u3 code gives the right answer, the problem occurs later on somehow the registers where the results are are getting walked on. Nick.