Consider: void bar (void); int global; void foo (unsigned char pedwarned, unsigned char warned) { unsigned char tem = warned | pedwarned; if (tem == 0) { if (global) warned = 1; } tem = warned | pedwarned; if (tem != 0) bar (); } Notice that if we get to "warned = 1;", we know we are going to call bar. However, the tree optimizers do not notice this. The RTL optimizers do find this optimization opportunity. Reduced from c-decl.c:duplicate_decls.
Confirmed, related to PR 18832. Note on PPC at least we don't really thread the jumps that well on the rtl level: _foo: or. r0,r4,r3 bne- cr0,L2 lis r2,ha16(_global) ori r0,r3,1 lwz r2,lo16(_global)(r2) cmpwi cr6,r0,0 cmpwi cr7,r2,0 beqlr- cr7 beqlr- cr6 L2: b _bar Now if we change all the unsigned char to _Bool we get the threaded jump: _foo: or. r0,r4,r3 bne- cr0,L2 lis r2,ha16(_global) lwz r2,lo16(_global)(r2) cmpwi cr7,r2,0 beqlr- cr7 L2: b _bar
This is not fixed by Jeff's latest threader patch.
Correct, it's not fixed. I have an idea why, but haven't really investigated yet.
This appears to work now...
Confirmed as fixed.