[PATCH] Fix doloop ICE (PR rtl-optimization/80112)

Jeff Law law@redhat.com
Fri Mar 24 12:37:00 GMT 2017


On 03/21/2017 09:00 AM, Jakub Jelinek wrote:
> Hi!
>
> doloop_condition_get computes cmp in several places, and in one of them
> wants to fail if the condition inside of it isn't NE against const0_rtx.
> The problem with that is that nothing checked what cmp is yet,
>   /* Check for (set (pc) (if_then_else (condition)
>                                        (label_ref (label))
>                                        (pc))).  */
>   if (GET_CODE (cmp) != SET
>       || SET_DEST (cmp) != pc_rtx
>       || GET_CODE (SET_SRC (cmp)) != IF_THEN_ELSE
>       || GET_CODE (XEXP (SET_SRC (cmp), 1)) != LABEL_REF
>       || XEXP (SET_SRC (cmp), 2) != pc_rtx)
>     return 0;
> is checked only a couple of lines later.
>
> To fix this, either we can use the following patch which guards the
> early check with the necessary subset of the later check, or we could
> for
>       if (GET_CODE (cmp) != SET || GET_CODE (SET_SRC (cmp)) != IF_THEN_ELSE)
> 	return 0;
> before cond = XEXP (SET_SRC (cmp), 0);,
> or set some bool flag and only verify this requirement if the bool flag
> is true after the later check.
>
> Any preferences?  The following has been successfully bootstrapped/regtested
> on powerpc64le-linux.
>
> 2017-03-21  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR rtl-optimization/80112
> 	* loop-doloop.c (doloop_condition_get): Don't check condition
> 	if cmp isn't SET with IF_THEN_ELSE src.
>
> 	* gcc.dg/pr80112.c: New test.
This code is a bit of a mess.  I could argue for at least 3 approaches 
to fix the bug, none of which I particularly like.

Yours isn't any worse than the other approaches, so let's just go with it.

OK.
jeff




More information about the Gcc-patches mailing list