This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
On Fri, Jun 9, 2017 at 3:04 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jun 09, 2017 at 02:35:45PM +0200, Richard Biener wrote:
>> +static bool
>> +gimple_fold_builtin_bcmp (gimple_stmt_iterator *gsi)
>> +{
>>
>> + /* Transform bcmp (a, b, len) into memcmp (a, b, len). */
>> +
>> + gimple *stmt = gsi_stmt (*gsi);
>> + tree a = gimple_call_arg (stmt, 0);
>> + tree b = gimple_call_arg (stmt, 1);
>> + tree len = gimple_call_arg (stmt, 2);
>> +
>> + gimple_seq seq = NULL;
>> + gimple *repl = gimple_build_call (fn, 3, a, b, len);
>> + gimple_seq_add_stmt_without_update (&seq, repl);
>> + gsi_replace_with_seq_vops (gsi, seq);
>>
>> given they have the same prototype you can do like gimple_fold_builtin_stpcpy:
>>
>> gimple_call_set_fndecl (stmt, fn);
>> fold_stmt (gsi);
>>
>> That works even with bcopy -> memmove if you swap arguments.
>
> Shouldn't it also update gimple_call_fntype though, at least for memmove?
> Those differ with void const * vs. void * arguments, and also in the return
> value. At least if the old fntype is compatible with the bcopy call.
Yes. If the old fntype isn't compatible we don't reach the folding.
Richard.
> Jakub
- References:
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- From: Bernhard Reutner-Fischer
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)
- Re: [PATCH] handle bzero/bcopy in DSE and aliasing (PR 80933, 80934)