Messages in this thread | | | Date | Fri, 12 Apr 1996 15:42:00 -0700 | From | (Tom May) | Subject | Re: gcc 2.7.2 common subexpression bug with possible kernel imp |
| |
Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> writes:
>On 10 Apr 96 at 10:49, Tom May wrote:
>> I just sent a bug report and patch to bug-gcc concerning a problem in >> gcc 2.7.2 common subexpression elimination that has possible >> implications in the linux kernel.
[...]
>This is a classical aliasing situation; you are modifying *p >indirectly via buf. I think almost every compiler assumes >"no-pointer-aliasing" when optimizing; otherwise it's very hard to >optimize.
When I was looking at the source to cse.c in gcc, it was apparent that gcc does not assume no-pointer-aliasing. I suppose it could actually make better code in some (many?) cases if it did. The cse stuff will assume all memory is clobbered by a write to a non-fixed address, such as through a pointer. In this case, the write is to a fixed address but the __asm__ contains an explicit clobber for "memory". But that clobber is falling through a crack in the logic and not being honored because it is inside the `if' and the code to handle this situation is slightly broken. It is clearly intended that it be honored.
It may not be difficult to add a -fassume-no-aliasing switch to the compiler to get the behavior you mention, though.
Tom.
| |