Bug 83213 - [8 Regression] peephole bug with -O2
Summary: [8 Regression] peephole bug with -O2
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 8.0
: P3 normal
Target Milestone: 8.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2017-11-29 10:19 UTC by David Binderman
Modified: 2018-01-16 08:59 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-*-*, i?86-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-01-15 00:00:00


Attachments
gzipped C source code (354.68 KB, application/gzip)
2017-11-29 10:19 UTC, David Binderman
Details
C source code (18.12 KB, text/plain)
2017-11-30 09:41 UTC, David Binderman
Details
gcc8-pr83213.patch (399 bytes, patch)
2018-01-15 15:51 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Binderman 2017-11-29 10:19:03 UTC
Created attachment 42741 [details]
gzipped C source code

The attached C code, when compiled by recent gcc trunk and flag -O2,
does this:

zend_vm_execute.h:63744:1: error: No region crossing jump at section boundary in bb 2545
 }

It compiled fine without the -O2 flag.

I'll have a go at finding a range of gcc revisions where
the problem seems to occur and I'll have a go at reducing the code.

I make this the 400th bug I've reported since Oct 2010.
Comment 1 David Binderman 2017-11-29 10:42:51 UTC
Bug seems to occur between revisions 253840 and 253974.
Comment 2 Jakub Jelinek 2017-11-29 15:13:01 UTC
That is weird, because already e.g. r250000 ICEs with:
internal compiler error: in to_reg_br_prob_base, at profile-count.h:189
and so does r253842.
It is true that r253974 ICEs differently, as you wrote.
Comment 3 David Binderman 2017-11-30 09:41:46 UTC
Created attachment 42749 [details]
C source code

After 12 hours reducing, this is what I got.

I think creduce isn't very fast, in some cases.
Comment 4 Jakub Jelinek 2017-11-30 10:46:12 UTC
My bisection says it starts with r249104, but that doesn't make sense, so it is likely r249097 or r249098 or some other change from that time.
Comment 5 Martin Liška 2017-12-20 12:37:09 UTC
(In reply to Jakub Jelinek from comment #4)
> My bisection says it starts with r249104, but that doesn't make sense, so it
> is likely r249097 or r249098 or some other change from that time.

One needs to tweak a bit flags, so with:

$ gcc pr83213.c  -O2 -Wno-implicit-function-declaration -c -freorder-functions -freorder-blocks-and-partition -fprofile-use

It started in r249013 which is:

SVN revision: 249013
Author: hubicka

	* predict.c (maybe_hot_bb_p): Do not check profile status.
	(maybe_hot_edge_p): Likewise.
	(probably_never_executed): Check for zero counts even if profile
	is not read.
	(unlikely_executed_edge_p): New function.
	(unlikely_executed_stmt_p): New function.
	(unlikely_executed_bb_p): New function.
	(set_even_probabilities): Use unlikely predicates.
	(combine_predictions_for_bb): Likewise.
	(predict_paths_for_bb): Likewise.
	(predict_paths_leading_to_edge): Likewise.
	(determine_unlikely_bbs): New function.
	(estimate_bb_frequencies): Use it.
	(compute_function_frequency): Use zero counts even if profile is
	not read.
	* profile-count.h: Fix typo.

	* g++.dg/tree-ssa/counts-1.C: New testcase.
	* gcc.dg/tree-ssa/counts-1.c: New testcase.

It's also not real trigger as it only fixes some predicates related to hotness of a basic-block.
Comment 6 Jakub Jelinek 2018-01-15 15:51:45 UTC
Created attachment 43139 [details]
gcc8-pr83213.patch

Untested fix.  No testcase, as even the reduced one is way too large.
Comment 7 Jakub Jelinek 2018-01-16 08:54:35 UTC
Author: jakub
Date: Tue Jan 16 08:54:03 2018
New Revision: 256728

URL: https://gcc.gnu.org/viewcvs?rev=256728&root=gcc&view=rev
Log:
	PR rtl-optimization/83213
	* recog.c (peep2_attempt): Copy over CROSSING_JUMP_P from peepinsn
	to last if both are JUMP_INSNs.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/recog.c
Comment 8 Jakub Jelinek 2018-01-16 08:59:21 UTC
Fixed.