Bug 47447

Summary: [4.4 Regression] "Unable to coalesce ssa_names <x> and <y>" ICE in tree-ssa-coalesce.c when -O3 is used
Product: gcc Reporter: asharif
Component: tree-optimizationAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal Keywords: ice-on-valid-code
Priority: P2    
Version: 4.4.6   
Target Milestone: 4.5.0   
Host: Target:
Build: Known to work: 4.2.4, 4.5.0, 4.5.1, 4.6.0
Known to fail: 4.3.0, 4.3.5, 4.4.0, 4.4.4 Last reconfirmed: 2011-01-25 11:00:44
Attachments: This is the input file to the compiler that produces an ICE.
This patch fixes the problem, but may be pessimistic.

Description asharif 2011-01-24 21:16:34 UTC
Created attachment 23110 [details]
This is the input file to the compiler that produces an ICE.

To reproduce, use the attached file and run:

g++ -o /dev/null -S -O3 reduced.manual.inline.cc

You will get this message:

Unable to coalesce ssa_names <x> and <y> which are marked as MUST COALESCE.

This is reproducible with the latest (as of Jan 20th, 2011) 4-4 branch of gcc. It seems to not happen with the trunk.
Comment 1 Richard Biener 2011-01-25 11:00:44 UTC
Confirmed.
Comment 2 asharif 2011-01-26 21:50:26 UTC
It seems like this bug is reproducible on older versions of the trunk.

This change:

http://gcc.gnu.org/viewcvs?view=revision&revision=146776

seems to suppress it (or fix it?). Jan Hubicka is the original author of this patch (from pretty-ipa I believe) and Richard brought it into mainline.

Jan, can you comment on this bug and confirm that your change does indeed fix it?
Comment 3 asharif 2011-02-03 22:19:10 UTC
Created attachment 23242 [details]
This patch fixes the problem, but may be pessimistic.
Comment 4 asharif 2011-02-03 22:19:37 UTC
Richard, check out the attached patch and let me know your thoughts.
Comment 5 Andrew Pinski 2011-02-03 22:23:36 UTC
I almost want to say LOOP_VINFO_NITERS should not have abnormal SSA's to begin with.
Comment 6 asharif 2011-02-03 22:25:01 UTC
What happens is tree vectorization introduces code in the preheader to check for the loop iterations at runtime. The expression holding the number of iterations may contain ssa names that are abnormal. This may extend their live range (that is what happens in this testcase) and make them conflict with other abnormal names.

That leads to an ICE.

I wonder what the other passes do that hoist such code effectively extending the live ranges of abnormal ssa names.
Comment 7 asharif 2011-02-03 22:26:48 UTC
(In reply to comment #5)
> I almost want to say LOOP_VINFO_NITERS should not have abnormal SSA's to begin
> with.

Andrew, shouldn't it be fine to have abnormal SSAs as long as they don't conflict? That may be the best solution -- i.e. bailing out only if they will conflict later on, as opposed to what my patch does (it bails out as soon as an abnormal name is detected).
Comment 8 asharif 2011-03-01 19:39:49 UTC
Ping. Andrew or Richard, how can I rework my patch to address this issue?

Thanks,
Comment 9 Richard Biener 2011-06-27 12:14:40 UTC
4.3 branch is being closed, moving to 4.4.7 target.
Comment 10 Jakub Jelinek 2012-03-13 13:04:29 UTC
Fixed in 4.5+, 4.4 is no longer supported.