This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Bug tree-optimization] Fix for PR71994
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: kugan <kugan dot vivekanandarajah at linaro dot org>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Jeff Law <law at redhat dot com>
- Date: Tue, 26 Jul 2016 13:48:41 +0200
- Subject: Re: [Bug tree-optimization] Fix for PR71994
- Authentication-results: sourceware.org; auth=none
- References: <a71404bf-d5f4-f83f-5bd9-c336cd732c64@linaro.org>
On Tue, Jul 26, 2016 at 5:13 AM, kugan
<kugan.vivekanandarajah@linaro.org> wrote:
> Hi,
>
> For testcase in pr71994, type of bb conditional result and the type of the
> PHI stmt are different (as om.0_1 is int and the first PHI argument is
> _bool; PHI stmt uses a constant zero that comes from edge 2). Therefore when
> we optimize final range test stmt, we end up setting integer 1 for other PHI
> argument. This results in ICE.
>
> <bb 2>:
> om.0_1 = om;
> _2 = om.0_1 >= 0;
> int _3 = (int) _2;
> if (om.0_1 != 0)
> goto <bb 3>;
> else
> goto <bb 4>;
>
> <bb 3>:
> int _4 = om.0_1 & _3;
> _Bool _12 = _4 != 0;
> <bb 4>:
>
> # _Bool _13 = PHI <0(2), _12(3)>
>
>
> IMHO, the fix should be that, we should check the type before replacing the
> value (punt otherwise). Attached patch does that. Bootstrapped and
> regression tested on x86_64-linux-gnu with no new regressions. Is this OK
> for trunk?
Ugh, this is undocumented spaghetti code I am not familiar with. I
can't see if it
is safe to truncate a constant here so I'd feel safer to just punt instead.
Richard.
> Thanks,
> Kugan
>
> gcc/testsuite/ChangeLog:
>
> 2016-07-26 Kugan Vivekanandarajah <kuganv@linaro.org>
>
> * gcc.dg/torture/pr71994.c: New test.
>
> gcc/ChangeLog:
>
> 2016-07-26 Kugan Vivekanandarajah <kuganv@linaro.org>
>
> * tree-ssa-reassoc.c (maybe_optimize_range_tests): Check type
> compatibility.
>