------- Comment #5 from jingyu at google dot com  2010-01-30 00:21 -------
>So the problem is really if (optimize_loop_for_size_p (loop)) .  I think you
>need to figure out why that is returning true.

That's because after unswitch-loop, one copy of the loop becomes cold. Let's
look at loop.cpp.

Before switch-loop pass, the loop (inner-most, hot) is

 loop {        
    if (obj != 0) {
      ...      <---- hot!
    }
  }

In function tree_unswitch_single_loop(),
after "nloop = tree_unswitch_loop (loop, bbs[i], cond)", the loop becomes

if (obj != 0) {
 loop {               <---- original copy of the loop
   if (obj != 0) { 
     ...    <---  hot!
   }
 }
} else {  <--- cold! becuase obj==0 is rarely seen
 loop {              <----- "nloop": a new copy of the loop
    if (obj != 0) {
      ...
    }
  }
}

nloop becomes a cold loop, but we still want to simplify its condition.
Otherwise, nloop becomes an empty loop in the end.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42720

Reply via email to