This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] Too conservative optimization with global variables??


In message <3EEDA327.2070402@student.tudelft.nl>, Steven Bosscher writes:
 >Consider:
 >
 >extern int c;
 >
 >void fubar (void)
 >{
 >  int a, b;
 >
 >  a = 1; b = 2; c = 3;
 >  c = a * b * c;
 >}
 >
 >With -O1 and -O2 this optimizes to (t15.optimized dump):
 >
 >;; Function fubar (fubar)
 >
 >fubar()
 >{
 >  int T.1;
 >  int a;
 >  int b;
 >
 >  c = 3;
 >  c = c * 2;
 >}
 >
 >Why can't this just be folded to "c = 6;"?
These days, it does compile to "c = 6" :-)


fubar ()
{
  # BLOCK 0
  # PRED: ENTRY [100.0%]  (fallthru,exec)
  #   c_8 = VDEF <c_6>;
  c = 6;
  return;
  # SUCC: EXIT [100.0%]

}


jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]