I am not sure if the original poster meant the same as I do. What I have
in mind is optimizations opportunities like the one of the following
linked list:

  struct list_element 
  {
     struct list_element *p_next;
     int *p_value;
  };
  int sum_list_values(const struct list_element *p_list)
  {
     int sum=0;
     for ( ; p_list ; p_list= p_list->p_next)
       if (p_list->p_value)
         sum += *p_list->p_value;
     return sum;
  }

Now, if the programmer wants to gain 5% performance (or more), he 
might mmap /dev/zero to address 0x000000 such that
   *(*int)0 == 0

Then, the compiler or the coder could unroll the loop
to minimizes conditional branches:

  int sum_list_values(const struct list_element *p_list)
  {
     int sum=0;
     while (p_list)
     {
        sum += *p_list->p_value; // undefined if p_value == NULL
        p_list= p_list->p_next;
        sum += *p_list->p_value; // and undefined if p_list == NULL
        p_list= p_list->p_next;
     }
     return sum;
  }

It could be a big gain on architectures that can't do effective
predication of the load from p_list->p_value. 

I once heard that xlC did something like that on AIX, automatically.
Does GCC take advantage of,e.g., AIX's mapping of address 0x00000000
to zeros? Can GCC be easily taught to do so?


-- 
Michael


Quoting Mike Stump <[EMAIL PROTECTED]>:

> On Dec 31, 2005, at 10:51 AM, Paul Schlie wrote:
> > As although C/C++ define some expressions as having undefined  
> > semantics;
> 
> I'd rather it be called --do-what-i-mean.  :-)
> 
> Could you give us a hint at what all the semantics you would want to  
> change with this option?  Are their any code bases that you're trying  
> to compile?  Compilers that you're trying to be compatible with?
> 

Reply via email to