j
: Next unread message k
: Previous unread message j a
: Jump to all threads
j l
: Jump to MailingList overview
+static void filll(void) +{
- ucell value = POP();
- ucell count = POP();
- ucell *dest = (ucell *)cell2pointer(POP());
- int i;
- for (i = 0; i <= count / 4; i++) {
dest[i] = value;
- }
+}
Apple's code does:
int *dest ... ; for (i = count; i > 0; i -= 4) *dest++ = value;
which is not the same thing for huge count, or for count a multiple of four (like all callers I have seen use; you write a word too many).
Segher
Apple's code does:
int *dest ... ; for (i = count; i > 0; i -= 4) *dest++ = value;
Oh, and it does an unsigned 32-bit read for the (signed) count; this means that on 64-bit systems it does not work for negative count values. Not that it is ever called like that, heh.
Here's the code if you care (from 5.2.4f1, i.e. for G5 machines):
58c0: 7e 84 a3 78 mr r4,r20 58c4: 80 7f 00 00 lwz r3,0(r31) 58c8: 80 bf 00 04 lwz r5,4(r31) 58cc: 7c 63 1b 79 mr. r3,r3 58d0: 86 9f 00 08 lwzu r20,8(r31) 58d4: 3b ff 00 04 addi r31,r31,4 58d8: 40 81 00 14 ble 0x58ec 58dc: 34 63 ff fc addic. r3,r3,-4 58e0: 90 85 00 00 stw r4,0(r5) 58e4: 38 a5 00 04 addi r5,r5,4 58e8: 42 80 ff f0 bc 20,lt,0x58d8 58ec: 4e 80 00 20 blr
Segher
On 17/08/11 09:03, Segher Boessenkool wrote:
Apple's code does:
int *dest ... ; for (i = count; i > 0; i -= 4) *dest++ = value;
Oh, and it does an unsigned 32-bit read for the (signed) count; this means that on 64-bit systems it does not work for negative count values. Not that it is ever called like that, heh.
Here's the code if you care (from 5.2.4f1, i.e. for G5 machines):
58c0: 7e 84 a3 78 mr r4,r20 58c4: 80 7f 00 00 lwz r3,0(r31) 58c8: 80 bf 00 04 lwz r5,4(r31) 58cc: 7c 63 1b 79 mr. r3,r3 58d0: 86 9f 00 08 lwzu r20,8(r31) 58d4: 3b ff 00 04 addi r31,r31,4 58d8: 40 81 00 14 ble 0x58ec 58dc: 34 63 ff fc addic. r3,r3,-4 58e0: 90 85 00 00 stw r4,0(r5) 58e4: 38 a5 00 04 addi r5,r5,4 58e8: 42 80 ff f0 bc 20,lt,0x58d8 58ec: 4e 80 00 20 blr
Segher
Interesting. In that case William, rather than add it directly to the list of primitive words, can you add it into arch/ppc/qemu/init.c and then call bind_func() instead? (see bottom of the same file for an example). This will then keep it as PPC-specific.
ATB,
Mark.