This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix PR target/34403
- From: "Richard Guenther" <richard dot guenther at gmail dot com>
- To: "Eric Botcazou" <ebotcazou at libertysurf dot fr>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 10 Dec 2007 21:36:02 +0100
- Subject: Re: [PATCH] Fix PR target/34403
- References: <200712102117.41121.ebotcazou@libertysurf.fr>
On Dec 10, 2007 9:17 PM, Eric Botcazou <ebotcazou@libertysurf.fr> wrote:
> This is a regression present on the mainline. The ICE triggered by the
> attached C++ testcase can be reproduced with
>
> void foo(char *dest, char *src)
> {
> __builtin_memcpy (dest, src, 0xfffffffc);
> }
>
> pr34403.c: In function 'foo':
> pr34403.c:4: error: verify_flow_info: Wrong frequency of block 7 -1247
> pr34403.c:4: error: verify_flow_info: Wrong frequency of block 6 -2248
> pr34403.c:4: error: verify_flow_info: Wrong probability of edge 5->5 12499
> pr34403.c:4: error: verify_flow_info: Wrong probability of edge 5->6 -2499
> pr34403.c:4: internal compiler error: verify_flow_info failed
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <http://gcc.gnu.org/bugs.html> for instructions.
>
>
> The problem stems from the new string operation code in the i386 back-end,
> more specifically:
>
> static void
> expand_set_or_movmem_via_loop (rtx destmem, rtx srcmem,
> rtx destptr, rtx srcptr, rtx value,
> rtx count, enum machine_mode mode, int unroll,
> int expected_size)
> [...]
>
> if (expected_size != -1)
> {
> expected_size /= GET_MODE_SIZE (mode) * unroll;
> if (expected_size == 0)
> predict_jump (0);
> else if (expected_size > REG_BR_PROB_BASE)
> predict_jump (REG_BR_PROB_BASE - 1);
> else
> predict_jump (REG_BR_PROB_BASE - (REG_BR_PROB_BASE + expected_size /
> 2) / expected_size);
> }
> else
> predict_jump (REG_BR_PROB_BASE * 80 / 100);
>
> because expected_size is negative here.
>
>
> We could skip the prediction in this case, but then the compiler emits a loop
> whose counter overflows at runtime, so I think that the safest solution is to
> punt and to emit a call to memcpy instead.
>
> Tested on i586-suse-linux, OK for mainline?
>
Ok.
Thanks,
Richard.
> 2007-12-10 Eric Botcazou <ebotcazou@libertysurf.fr>
>
> PR target/34403
> * config/i386/i386.c (ix86_expand_movmem): Punt if the count is large.
> (ix86_expand_setmem): Likewise.
>
>
> 2007-12-10 Eric Botcazou <ebotcazou@libertysurf.fr>
>
> * g++.dg/opt/memcpy1.C: New test.
>
>
> --
> Eric Botcazou
>