------- Comment #3 from carrot at google dot com 2009-07-01 10:24 ------- (In reply to comment #2) > Subject: Re: New: unnecessary conversion from unsigned > byte load to signed byte load > > > > Unfortunately in thumb mode, loading a signed byte costs more than loading > > an > > unsigned byte and comparing with 0 has same cost as comparing with 0x7F. > > I don't know of any core where loading a signed byte is more expensive > than unsigned byte in thumb mode. What did you have in mind ? > > I suspect what you mean is that the sign extension here is not required > and we could get away with ldrb. > In thumb1, instruction ldrb has an addressing mode of Rn + imm5, but ldrsb has only addressing mode of Rn + Rm. So loading unsigned byte from p[8] needs only one instruction ldrb r3, [r0, 8]
But loading singed byte from p[8] needs two instructions: mov r3, 8 ldrsb r3, [r0, r3] So in this case (base + constant offset), loading a signed byte is more expensive than unsigned byte in thumb mode. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40603