Bug 12472 - [tree-ssa] [doloop] miscompiles stage-2's gengtype
Summary: [tree-ssa] [doloop] miscompiles stage-2's gengtype
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: tree-ssa
: P1 critical
Target Milestone: tree-ssa
Assignee: Not yet assigned to anyone
URL:
Keywords: build, wrong-code
: 12528 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-10-01 03:46 UTC by Andrew Pinski
Modified: 2003-11-18 22:53 UTC (History)
2 users (show)

See Also:
Host:
Target: powerpc-apple-darwin
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-11-04 05:25:48


Attachments
patch that disables some of the rtl optimizations which cause problems on ppc-darwin (452 bytes, text/plain)
2003-10-17 14:37 UTC, Andrew Pinski
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Pinski 2003-10-01 03:46:18 UTC
Read <http://gcc.gnu.org/ml/gcc/2003-09/msg01190.html> and <http://gcc.gnu.org/ml/gcc/
2003-09/msg01206.html>.
Main just is that GCC miscompiles gengtype's update_lineno which cause a segfault.
The main difference between powerpc-apple-darwin and any other target is that it defines 
BOOL_TYPE_SIZE to be INT_TYPE_SIZE (so that _Bool is of size 4 instead of 1).
Even trying with commenting that line out, bootstrap does not pass.
Also note that the problem is not the trees that are causing the problem so it might be a problem 
on the mainline also.
Comment 1 Andrew Pinski 2003-10-06 20:45:40 UTC
*** Bug 12528 has been marked as a duplicate of this bug. ***
Comment 2 Andrew Pinski 2003-10-14 21:17:26 UTC
If I disable all the RTL optimizers by editing opts.c and #if 0 out the code to turn them on, I get 
passed this point.
Comment 3 Andrew Pinski 2003-10-15 00:09:35 UTC
This is caused by one of the following two options:
      flag_loop_optimize = 1;
      flag_crossjumping = 1;

Both are RTL based optimizers, if I have some more time to work on this I will.
Comment 4 Andrew Pinski 2003-10-15 01:29:18 UTC
Okay I have narrowed it down to
      flag_loop_optimize = 1;

Now I need to find out what it is doing to cause the miscompile.
Comment 5 Andrew Pinski 2003-10-15 02:33:34 UTC
It is looking more like flag_branch_on_count_reg which is causing it.
Comment 6 Andrew Pinski 2003-10-15 03:32:14 UTC
I have verified that it is flag_branch_on_count_reg which is causing it, I will look more at 
it tomorrow.
Comment 7 Andrew Pinski 2003-10-16 00:36:37 UTC
This is another RTL optimization problem after the doloop optimization is fixed.
It is caused by one of following options:
      flag_optimize_sibling_calls = 1;
      flag_cse_follow_jumps = 1;
      flag_cse_skip_blocks = 1;
I am trying to narrow it down as I write this.
Comment 8 Andrew Pinski 2003-10-16 00:49:14 UTC
Down to two:
      flag_optimize_sibling_calls = 1;
      flag_cse_skip_blocks = 1;
Comment 9 Andrew Pinski 2003-10-16 02:16:20 UTC
So the final two options which are causing the miscompile on powerpc-darwin are:
      flag_optimize_sibling_calls = 1;  (-foptimize-sibling-calls)
flag_branch_on_count_reg (-fbranch-on-count-reg)
Both are enabled at -O2.
Comment 10 Andrew Pinski 2003-10-17 14:37:09 UTC
Created attachment 4949 [details]
patch that disables some of the rtl optimizations which cause problems on ppc-darwin
Comment 11 Andrew Pinski 2003-11-04 05:25:45 UTC
One more thing, the tree-ssa adds 
	addi r4,r4,-1 to the asm for some reason, other than that it is identical to the mainline.
Comment 12 Andrew Pinski 2003-11-18 22:53:20 UTC
What is cool is this patch is no longer needed so closing as fixed because it passes the spot where 
the problem is.