From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27962 invoked by alias); 14 Jun 2011 16:33:24 -0000 Received: (qmail 27954 invoked by uid 22791); 14 Jun 2011 16:33:23 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qy0-f182.google.com (HELO mail-qy0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 14 Jun 2011 16:33:08 +0000 Received: by qyk27 with SMTP id 27so3287195qyk.20 for ; Tue, 14 Jun 2011 09:33:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.99.80 with SMTP id t16mr5112189qcn.73.1308069187809; Tue, 14 Jun 2011 09:33:07 -0700 (PDT) Received: by 10.229.47.78 with HTTP; Tue, 14 Jun 2011 09:33:07 -0700 (PDT) In-Reply-To: References: <20110611150953.GA18253@intel.com> Date: Tue, 14 Jun 2011 16:53:00 -0000 Message-ID: Subject: Re: PATCH [1/n]: Prepare x32: PR middle-end/47364: internal compiler error: in emit_move_insn, at expr.c:3355 From: "H.J. Lu" To: Richard Guenther Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg01080.txt.bz2 On Tue, Jun 14, 2011 at 8:11 AM, Richard Guenther wrote: > On Sun, Jun 12, 2011 at 6:28 PM, H.J. Lu wrote: >> On Sun, Jun 12, 2011 at 7:33 AM, H.J. Lu wrote: >>> On Sun, Jun 12, 2011 at 7:00 AM, H.J. Lu wrote: >>>> On Sun, Jun 12, 2011 at 6:50 AM, Richard Guenther >>>> wrote: >>>>> On Sun, Jun 12, 2011 at 3:18 PM, H.J. Lu wrote: >>>>>> On Sun, Jun 12, 2011 at 3:48 AM, Richard Guenther >>>>>> wrote: >>>>>>> On Sat, Jun 11, 2011 at 5:09 PM, H.J. Lu wro= te: >>>>>>>> Hi, >>>>>>>> >>>>>>>> expand_builtin_strlen has >>>>>>>> >>>>>>>> src_reg =3D gen_reg_rtx (Pmode); >>>>>>>> ... >>>>>>>> pat =3D expand_expr (src, src_reg, ptr_mode, EXPAND_NORMAL); >>>>>>>> if (pat !=3D src_reg) >>>>>>>> =A0emit_move_insn (src_reg, pat); >>>>>>>> >>>>>>>> But src_reg may be in ptr_mode, wich may not be the same as Pmode. >>>>>>>> This patch checks it. =A0OK for trunk? >>>>>>>> >>>>>>>> Thanks. >>>>>>>> >>>>>>>> >>>>>>>> H.J. >>>>>>>> --- >>>>>>>> 2011-06-11 =A0H.J. Lu =A0 >>>>>>>> >>>>>>>> =A0 =A0 =A0 =A0PR middle-end/47364 >>>>>>>> =A0 =A0 =A0 =A0* builtins.c (expand_builtin_strlen): Properly hand= le target >>>>>>>> =A0 =A0 =A0 =A0not in Pmode. >>>>>>>> >>>>>>>> diff --git a/gcc/builtins.c b/gcc/builtins.c >>>>>>>> index 7b24a0c..4e2cf31 100644 >>>>>>>> --- a/gcc/builtins.c >>>>>>>> +++ b/gcc/builtins.c >>>>>>>> @@ -2941,7 +2941,11 @@ expand_builtin_strlen (tree exp, rtx target, >>>>>>>> =A0 =A0 =A0 start_sequence (); >>>>>>>> =A0 =A0 =A0 pat =3D expand_expr (src, src_reg, ptr_mode, EXPAND_NO= RMAL); >>>>>>>> =A0 =A0 =A0 if (pat !=3D src_reg) >>>>>>>> - =A0 =A0 =A0 emit_move_insn (src_reg, pat); >>>>>>>> + =A0 =A0 =A0 { >>>>>>>> + =A0 =A0 =A0 =A0 if (GET_MODE (pat) !=3D Pmode) >>>>>>>> + =A0 =A0 =A0 =A0 =A0 pat =3D convert_to_mode (Pmode, pat, 1); >>>>>>> >>>>>>> Shouldn't this be POINTERS_EXTEND_UNSIGNED instead of 1? >>>>>>> >>>>>>>> + =A0 =A0 =A0 =A0 emit_move_insn (src_reg, pat); >>>>>>> >>>>>>> Why not use convert_move unconditionally? >>>>>>> >>>>>>> Or, why not expand src in Pmode from the start? =A0After all, src_r= eg is >>>>>>> created as Pmode reg. >>>>>>> >>>>>> >>>>>> This patch works for my testcase. =A0OK for trunk? >>>>> >>>>> Ok if it passes bootstrap & regtest on a ptr_mode !=3D Pmode target. >>>>> >>>> >>>> Only the following targets expand strlen: >>>> >>>> avr/avr.md:(define_expand "strlenhi" >>>> avr/avr.md:(define_insn "*strlenhi" >>>> i386/i386.md:(define_expand "strlen" >>>> i386/i386.md: if (ix86_expand_strlen (operands[0], operands[1], >>>> operands[2], operands[3])) >>>> i386/i386.md:(define_expand "strlenqi_1" >>>> i386/i386.md:(define_insn "*strlenqi_1" >>>> rs6000/rs6000.md:(define_expand "strlensi" >>>> s390/s390.md:; strlenM instruction pattern(s). >>>> s390/s390.md:(define_expand "strlen" >>>> s390/s390.md:(define_insn "*strlen" >>>> >>>> None of them, except for my x32 port, are ptr_mode !=3D Pmode targets. >>>> I will bootstrap and test it on my x32 branch. >>>> >>> >>> It doesn't work on x32. I got >>> >>> /export/gnu/import/git/gcc-x32/libssp/gets-chk.c:74:14: internal >>> compiler error: in emit_move_insn, at expr.c:3319 >>> Please submit a full bug report, >>> with preprocessed source if appropriate. >>> See for instructions. >>> >>> How about this patch? >>> >>> Thanks. >> >> No regressions on x32 branch. =A0OK for trunk? > > Does it work with also doing the expansion to Pmode in the first > place? =A0If so, ok with that change. > This is the patch I checked in. Thanks. --=20 H.J. --- Index: builtins.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- builtins.c (revision 175033) +++ builtins.c (working copy) @@ -2939,9 +2939,16 @@ expand_builtin_strlen (tree exp, rtx tar /* Now that we are assured of success, expand the source. */ start_sequence (); - pat =3D expand_expr (src, src_reg, ptr_mode, EXPAND_NORMAL); + pat =3D expand_expr (src, src_reg, Pmode, EXPAND_NORMAL); if (pat !=3D src_reg) - emit_move_insn (src_reg, pat); + { +#ifdef POINTERS_EXTEND_UNSIGNED + if (GET_MODE (pat) !=3D Pmode) + pat =3D convert_to_mode (Pmode, pat, + POINTERS_EXTEND_UNSIGNED); +#endif + emit_move_insn (src_reg, pat); + } pat =3D get_insns (); end_sequence (); Index: ChangeLog =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- ChangeLog (revision 175033) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2011-06-14 H.J. Lu + + PR middle-end/47364 + * builtins.c (expand_builtin_strlen): Expand strlen to Pmode + and properly handle result not in Pmode. + 2011-06-14 Robert Millan * config/i386/kfreebsd-gnu.h: Resync with `config/i386/linux.h'.