I've re-written your test case a bit just to get rid of the Arduino stuff.
#include <stdint.h>
#include <string.h>
#include <avr/io.h>
/*
Comparison of two approaches to boolean logic
*/
void usart0Init(uint32_t);
void prt(uint8_t);
//=======1=========2=========3=========4=========5=========6=========7=========8
//=======1=========2=========3=========4=========5=========6 usart0Init
//
void usart0Init(uint32_t brate)
{
UCSR0A = 0 << TXC0 | 0 << U2X0 | 0 << MPCM0;
UCSR0B = (1 << RXCIE0 ) | (1 << RXEN0 ) | (1 << TXEN0 );
UCSR0C = (1 << UCSZ00 ) | (1 << UCSZ01 );
UBRR0 = ((F_CPU / 16) / brate) - 1;
}
//=======1=========2=========3=========4=========5=========6=========7=========8
//=======1=========2=========3=========4=========5=========6 prt
//
inline void prt(uint8_t x) {while(!(UCSR0A & (1<<UDRE0)));UDR0 = x;}
//=======1=========2=========3=========4=========5=========6=========7=========8
bool y;
bool z;
int main()
{
usart0Init(57600);
for (int i = 0; i < 16; i++) {
bool cond0 = i & 1;
bool cond1 = i & 2;
bool cond2 = i & 4;
bool cond3 = i & 8;
//if ((cond0 or cond1) and !cond2 and !cond3) {
// z = true;
//}
//else z = false;
//
// versus
//
y = (cond0 or cond1) and !cond2 and !cond3;
prt(y + 48);
prt(32);
prt(z + 48);
prt(10);
}
while(1) {
// put your main code here, to run repeatedly:
}
}
using the boolean, compiles to 256(262 outside from IDE) bytes. Changing to,
if ((cond0 or cond1) and !cond2 and !cond3) {
z = true;
}
else z = false;
// versus
//
//y = (cond0 or cond1) and !cond2 and !cond3;
compiles to 264(234 outside from IDE) bytes.
main() for if test,
0000009e <main>:
9e: 10 92 c0 00 sts 0x00C0, r1 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0>
a2: 88 e9 ldi r24, 0x98 ; 152
a4: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__TEXT_REGION_LENGTH__+0x7e00c1>
a8: 86 e0 ldi r24, 0x06 ; 6
aa: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__TEXT_REGION_LENGTH__+0x7e00c2>
ae: 80 e1 ldi r24, 0x10 ; 16
b0: 90 e0 ldi r25, 0x00 ; 0
b2: 90 93 c5 00 sts 0x00C5, r25 ; 0x8000c5 <__TEXT_REGION_LENGTH__+0x7e00c5>
b6: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__TEXT_REGION_LENGTH__+0x7e00c4>
ba: d0 e0 ldi r29, 0x00 ; 0
bc: c0 e0 ldi r28, 0x00 ; 0
be: 11 e0 ldi r17, 0x01 ; 1
c0: ce 01 movw r24, r28
c2: 83 70 andi r24, 0x03 ; 3
c4: 99 27 eor r25, r25
c6: 89 2b or r24, r25
c8: c9 f0 breq .+50 ; 0xfc <main+0x5e>
ca: ce 01 movw r24, r28
cc: 8c 70 andi r24, 0x0C ; 12
ce: 99 27 eor r25, r25
d0: 89 2b or r24, r25
d2: a1 f4 brne .+40 ; 0xfc <main+0x5e>
d4: 10 93 00 01 sts 0x0100, r17 ; 0x800100 <_edata>
d8: 80 e0 ldi r24, 0x00 ; 0
da: 0e 94 48 00 call 0x90 ; 0x90 <_Z3prth>
de: 80 e2 ldi r24, 0x20 ; 32
e0: 0e 94 48 00 call 0x90 ; 0x90 <_Z3prth>
e4: 80 91 00 01 lds r24, 0x0100 ; 0x800100 <_edata>
e8: 0e 94 48 00 call 0x90 ; 0x90 <_Z3prth>
ec: 8a e0 ldi r24, 0x0A ; 10
ee: 0e 94 48 00 call 0x90 ; 0x90 <_Z3prth>
f2: 21 96 adiw r28, 0x01 ; 1
f4: c0 31 cpi r28, 0x10 ; 16
f6: d1 05 cpc r29, r1
f8: 19 f7 brne .-58 ; 0xc0 <main+0x22>
fa: ff cf rjmp .-2 ; 0xfa <main+0x5c>
fc: 10 92 00 01 sts 0x0100, r1 ; 0x800100 <_edata>
100: eb cf rjmp .-42 ; 0xd8 <main+0x3a>
main() for bool test,
0000008e <main>:
8e: 10 92 c0 00 sts 0x00C0, r1 ; 0x8000c0 <__TEXT_REGION_LENGTH__+0x7e00c0>
92: 88 e9 ldi r24, 0x98 ; 152
94: 80 93 c1 00 sts 0x00C1, r24 ; 0x8000c1 <__TEXT_REGION_LENGTH__+0x7e00c1>
98: 86 e0 ldi r24, 0x06 ; 6
9a: 80 93 c2 00 sts 0x00C2, r24 ; 0x8000c2 <__TEXT_REGION_LENGTH__+0x7e00c2>
9e: 80 e1 ldi r24, 0x10 ; 16
a0: 90 e0 ldi r25, 0x00 ; 0
a2: 90 93 c5 00 sts 0x00C5, r25 ; 0x8000c5 <__TEXT_REGION_LENGTH__+0x7e00c5>
a6: 80 93 c4 00 sts 0x00C4, r24 ; 0x8000c4 <__TEXT_REGION_LENGTH__+0x7e00c4>
aa: d0 e0 ldi r29, 0x00 ; 0
ac: c0 e0 ldi r28, 0x00 ; 0
ae: ce 01 movw r24, r28
b0: 83 70 andi r24, 0x03 ; 3
b2: 99 27 eor r25, r25
b4: 89 2b or r24, r25
b6: 31 f0 breq .+12 ; 0xc4 <main+0x36>
b8: 81 e0 ldi r24, 0x01 ; 1
ba: 9e 01 movw r18, r28
bc: 2c 70 andi r18, 0x0C ; 12
be: 33 27 eor r19, r19
c0: 23 2b or r18, r19
c2: 09 f0 breq .+2 ; 0xc6 <main+0x38>
c4: 80 e0 ldi r24, 0x00 ; 0
c6: 0e 94 40 00 call 0x80 ; 0x80 <_Z3prth>
ca: 80 e2 ldi r24, 0x20 ; 32
cc: 0e 94 40 00 call 0x80 ; 0x80 <_Z3prth>
d0: 80 e0 ldi r24, 0x00 ; 0
d2: 0e 94 40 00 call 0x80 ; 0x80 <_Z3prth>
d6: 8a e0 ldi r24, 0x0A ; 10
d8: 0e 94 40 00 call 0x80 ; 0x80 <_Z3prth>
dc: 21 96 adiw r28, 0x01 ; 1
de: c0 31 cpi r28, 0x10 ; 16
e0: d1 05 cpc r29, r1
e2: 29 f7 brne .-54 ; 0xae <main+0x20>
e4: ff cf rjmp .-2 ; 0xe4 <main+0x56>