This is the mail archive of the gcc-bugs@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]

[Bug optimization/13681] [tree-ssa] ICE in get_expr_operands with out-of-bounds access


------- Additional Comments From steven at gcc dot gnu dot org  2004-01-16 12:13 -------
The key problem here is that we cannot fold the out-of-bounds 
array reference.  For the first dominator optimization pass, we 
start with the following: 
 
void foo() () 
{ 
  unsigned int T.1; 
  double & <D1486>; 
  struct X * const this; 
  const unsigned int index; 
  struct X h1; 
  double d; 
  double & T.2; 
  double & retval.3; 
 
  # BLOCK 0 
  # PRED: ENTRY (fallthru) 
  this_1 = &h1; 
  index_2 = 0;               // Or 1 for the case that fails 
  T.1_3 = index_2 * 8; 
  <D1486>_4 = T.1_3 + this_1; 
  retval.3_5 = <D1486>_4; 
  T.2_6 = retval.3_5; 
  *T.2_6 = d_7; 
  return; 
  # SUCC: EXIT 
 
} 
 
 
Them DOM1 goes to work and we replace T.2_6 
 
<   Replaced 'T.2_6' with constant '&h1 + 8' 
--- 
>   Replaced 'T.2_6' with constant '&h1.values[0]' 
>   Folded to: h1.values[0] = d_7; 
 
So for the index==0 case, we have h1.values[0] = d_7; 
and for the index==1 case, we get *(&h1 + 8) = d_7; 
 
We cannot fold the latter to an array reference, and this 
causes us to abort in get_expr_operands on something with 
a comment that only the folded case can be handled: 
 
tree-ssa-operands.c: 
916      /* Everything else should have been folded elsewhere.  */ 
917      else 
918        abort (); 
 
I was surprised to see that "*(&h1 + 8)" is a valid GIMPLE lvalue 
according to is_gimple_lvalue().  I would think this address needs 
to be loaded in a temporary.  Apparently we're assuming optimistically 
somewhere that we can always fold these indirect references for  
array types, and this assumption is incorrect. 

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at redhat dot com


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


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