12340 – [3.3 regression] loop unroller + gcse produces wrong code (original) (raw)
Description Richard Biener 2003-09-19 15:10:42 UTC
If compiling with -O2 -fno-exceptions -funroll-loops the testcase segfaults in a destructor, with -fno-gcse added or -funroll-loops removed, the testcase is fine. This problem does not appear on gcc 3.2.3 or gcc 3.4 with either -funroll-loops or -fold-unroll-loops.
Testcase is available from
http://www.tat.physik.uni-tuebingen.de/~rguenth/gcc/brick_test1.bug.ii.gz
gcc-3.3 version tested is
g++-3.3 (GCC) 3.3.2 20030919 (prerelease)
Richard.
Comment 1 Eric Botcazou 2003-09-22 06:03:07 UTC
Any chance that you could shrink down the 50000-line testcase? Trying to do it without knowing the code is a bit painful.
Comment 2 Richard Biener 2003-09-22 08:01:58 UTC
Subject: Re: [3.3 regression] loop unroller + gcse produces wrong code
On 22 Sep 2003, ebotcazou at gcc dot gnu dot org wrote:
------- Additional Comments From ebotcazou at gcc dot gnu dot org 2003-09-22 06:03 ------- Any chance that you could shrink down the 50000-line testcase? Trying to do it without knowing the code is a bit painful.
The testcase is
#include "Domain/Interval.h" #include "Engine/BrickEngine.h"
#include "../../Engine/BrickBase.cpp" #include "../../Utilities/Unique.cmpl.cpp"
namespace Pooma { int myContext_g; }
typedef Engine<1,double,Brick> Array_t;
int main(int argc, char argv[]) { Interval<1> I(10); Array_t A(I); for (int i = 0; i < 10; i++) A(Loc<1>(i)) = 2.0 + i - ii; return 0; }
unfortunately, this pulls in nearly all of the POOMA library (although most of it is unused, of course). Sadly delta is not very good/fast at reducing C++ testcases. Maybe the tree-ssa pretty-printer can output only the used parts? Or maybe you can assist me in reducing such C++ testcases (aka stripping unused parts of the code).
After all, the assembly file of the testcase is only 11k big and it seems to be a problem with the destructor handling? But I can't see anything obvious either.
Richard.
-- Richard Guenther WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
Comment 3 Eric Botcazou 2003-09-22 15:14:34 UTC
Is it mandatory to include the two *.cpp files? Can you break them apart and include only the necessary bits?
Comment 4 Eric Botcazou 2003-09-22 15:17:09 UTC
The loop optimizer thinks the loop in main() is executed 6 times!!! I'm going to teach it how to count :-)
Comment 5 Richard Biener 2003-09-22 15:25:16 UTC
Subject: Re: [3.3 regression] loop unroller + gcse produces wrong code
On 22 Sep 2003, ebotcazou at gcc dot gnu dot org wrote:
The loop optimizer thinks the loop in main() is executed 6 times!!! I'm going to teach it how to count :-)
I cannot see how this then should produce a SIGSEGV at destruction time, but if it is true, then its worth to fix for sure ;)
Richard.
-- Richard Guenther WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/
Comment 6 Eric Botcazou 2003-09-22 16:37:04 UTC
This fools the loop unroller, which produces code that overwrites some fields of the object on the stack.