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: g++ 4.3, troubles with C++ indexing idioms


On 19 July 2007 20:38, tbp wrote:

> On 7/19/07, Dave Korn wrote:
>>   Bogus codegen is the inevitable result of bogus code.  Garbage in,
>> garbage out. 
>> 
>>   BTW, the const indexing is completely undefined too.
> That's the kind of answer i'd get from gcc-help and at that point i'd
> be none wiser because i already know that. I also know that up to
> gcc-4.3-20070608 it was provably giving correct results faster than
> any other variants. Being no language lawyer, that's the only metric i
> consider.
> It's no portability issue either because every compiler asks for a
> specific work around; which is quite sad considering how mundane that
> code is.

  The "workaround" is to just do it right in the first place: union the three
single ints with the array of three.  That way you won't mislead the aliasing
and dataflow analysis.  If you really analysed the generated code in great
depth, you'd be able to classify all the differences between the codegen when
you do it the right way and the codegen when you do it your original way into
two categories: a) missed optimisations, and b) extra instructions that are
actually needed for technical correctness in aliasing situations.  Those in
category a) you can file PRs and they'll be fixed if possible; those in
category b) would actually be bad codegen if the compiler generated the same
code for the array/union case as it did for your pointer-arithmetic-abuse
case, although in some cases you might be able to use restricted pointers to
get back to the kind of codegen you're looking for.


    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


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