------- Comment #5 from bonzini at gnu dot org 2005-12-17 10:27 ------- Well, another work around should probably be (untested)
Confirmed, reduced testcase: void f(void*); void *g(void); void _aie_malloc(unsigned int size) { void *aie_memory_heap_ptr; if (__builtin_expect(size != 0, true) { aie_memory_heap_ptr = g(); if (__builtin_expect (aie_memory_heap_ptr != 0, 1)) f(aie_memory_heap_ptr); } } This could be fixed also by folding __builtin_expect of &&, ||, and = like this: __b_e (a && b, 1) => __b_e (a, 1) && __b_e (b, 1) __b_e (a && b, 0) => a && __b_e (b, 0) __b_e (a || b, 1) => a || __b_e (b, 1) __b_e (a || b, 0) => __b_e (a, 0) || __b_e (b, 0) __b_e (x, y) => (save_expr (x), __b_e (save_expr (x), y)) (*) (*) when x has side effects This could even produce better code (I remember a bug about worse code produced when putting complex expression within __builtin_expect, but it might be resolved as of now). -- bonzini at gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bonzini at gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21513