Issue 21 in libfixmath: >= 0 comparison might be more efficient than > 0 comparison

8 views
Skip to first unread message

libfi...@googlecode.com

unread,
Jan 27, 2013, 3:14:35 PM1/27/13
to libfi...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 21 by georgjoh...@web.de: >= 0 comparison might be more efficient
than > 0 comparison
http://code.google.com/p/libfixmath/issues/detail?id=21

What steps will reproduce the problem?
1. avr-gcc -Os -S -mmcu=atmega8 fix16.c
2. Read .s file

What is the expected output? What do you see instead?

This is a diff of sequences from fix16.c:fix16_sadd resp.
fix16.c:fix16_ssub. There is a comparison >0 that can be replaced by a
comparison >= 0. Comparisons >= 0 might be more efficient on some systems
because only the sign bit needs to be tested. AVR is an example. In this
test, it does not matter whether >=0 or >0 is used:

diff fix16-a.s fix16-b.s
23,27c23,24
< cp __zero_reg__,r12
< cpc __zero_reg__,r13
< cpc __zero_reg__,r14
< cpc __zero_reg__,r15
< brge .L13
---
> sbrc r15,7
> rjmp .L13
76,80c73,74
< cp __zero_reg__,r12
< cpc __zero_reg__,r13
< cpc __zero_reg__,r14
< cpc __zero_reg__,r15
< brge .L17
---
> sbrc r15,7
> rjmp .L17


What version of the product are you using? On what operating system?

r64, hosted on avr-unknown-none


Attachments:
opt.diff 579 bytes
fix16-a.s 1.6 KB
fix16-b.s 1.5 KB

libfi...@googlecode.com

unread,
Jan 28, 2013, 10:49:13 AM1/28/13
to libfi...@googlegroups.com
Updates:
Status: Fixed

Comment #1 on issue 21 by Petteri.Aimonen: >= 0 comparison might be more
This issue was closed by revision r85.

Reply all
Reply to author
Forward
0 new messages