On Sun, Jun 12, 2011 at 3:48 AM, Richard Guenther <richard.guent...@gmail.com> wrote: > On Sat, Jun 11, 2011 at 5:09 PM, H.J. Lu <hongjiu...@intel.com> wrote: >> Hi, >> >> expand_builtin_strlen has >> >> src_reg = gen_reg_rtx (Pmode); >> ... >> pat = expand_expr (src, src_reg, ptr_mode, EXPAND_NORMAL); >> if (pat != src_reg) >> emit_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. OK for trunk? >> >> Thanks. >> >> >> H.J. >> --- >> 2011-06-11 H.J. Lu <hongjiu...@intel.com> >> >> PR middle-end/47364 >> * builtins.c (expand_builtin_strlen): Properly handle target >> not 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, >> start_sequence (); >> pat = expand_expr (src, src_reg, ptr_mode, EXPAND_NORMAL); >> if (pat != src_reg) >> - emit_move_insn (src_reg, pat); >> + { >> + if (GET_MODE (pat) != Pmode) >> + pat = convert_to_mode (Pmode, pat, 1); > > Shouldn't this be POINTERS_EXTEND_UNSIGNED instead of 1? > >> + emit_move_insn (src_reg, pat); > > Why not use convert_move unconditionally? > > Or, why not expand src in Pmode from the start? After all, src_reg is > created as Pmode reg. >
This patch works for my testcase. OK for trunk? Thanks. -- H.J. ---- 2011-06-12 H.J. Lu <hongjiu...@intel.com> PR middle-end/47364 * builtins.c (expand_builtin_strlen): Expand strlen to Pmode. diff --git a/gcc/builtins.c b/gcc/builtins.c index 7b24a0c..7db4e6d 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -2939,7 +2939,7 @@ expand_builtin_strlen (tree exp, rtx target, /* Now that we are assured of success, expand the source. */ start_sequence (); - pat = expand_expr (src, src_reg, ptr_mode, EXPAND_NORMAL); + pat = expand_expr (src, src_reg, Pmode, EXPAND_NORMAL); if (pat != src_reg) emit_move_insn (src_reg, pat); pat = get_insns ();