skzlzl / libfixmath

Automatically exported from code.google.com/p/libfixmath
0 stars 0 forks source link

>= 0 comparison might be more efficient than > 0 comparison #21

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by georgjoh...@web.de on 27 Jan 2013 at 8:14

Attachments:

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r85.

Original comment by Petteri.Aimonen on 28 Jan 2013 at 3:49