* [PATCH][stage1] Refactor gimple_fold_builtin_memory_op function.
@ 2019-03-12 9:26 Martin Liška
2019-04-29 20:29 ` Jeff Law
0 siblings, 1 reply; 2+ messages in thread
From: Martin Liška @ 2019-03-12 9:26 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
Hi.
The patch is about simplification and usage of enum types. ENDP integer
does not make much sense in this usage.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed after stage1 opens?
Thanks,
Martin
2019-03-11 Martin Liska <mliska@suse.cz>
* gimple-fold.c (gimple_fold_builtin_memory_op): Change endp
into built_in_function enum. Remove code for endp == 2 and
use BUILT_IN_* constants.
(gimple_fold_builtin): Call the function with fcode.
---
gcc/gimple-fold.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
[-- Attachment #2: 0001-Refactor-gimple_fold_builtin_memory_op-function.patch --]
[-- Type: text/x-patch, Size: 2158 bytes --]
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c
index 62d2e0abc26..e0da5ef6723 100644
--- a/gcc/gimple-fold.c
+++ b/gcc/gimple-fold.c
@@ -692,7 +692,7 @@ size_must_be_zero_p (tree size)
static bool
gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
- tree dest, tree src, int endp)
+ tree dest, tree src, enum built_in_function code)
{
gimple *stmt = gsi_stmt (*gsi);
tree lhs = gimple_call_lhs (stmt);
@@ -839,7 +839,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
}
}
- if (endp == 3)
+ if (code == BUILT_IN_MEMMOVE)
{
/* Both DEST and SRC must be pointer types.
??? This is what old code did. Is the testing for pointer types
@@ -1102,17 +1102,16 @@ set_vop_and_replace:
done:
gimple_seq stmts = NULL;
- if (endp == 0 || endp == 3)
+ if (code == BUILT_IN_MEMCPY || code == BUILT_IN_MEMMOVE)
len = NULL_TREE;
- else if (endp == 2)
- len = gimple_build (&stmts, loc, MINUS_EXPR, TREE_TYPE (len), len,
- ssize_int (1));
- if (endp == 2 || endp == 1)
+ else if (code == BUILT_IN_MEMPCPY)
{
len = gimple_convert_to_ptrofftype (&stmts, loc, len);
dest = gimple_build (&stmts, loc, POINTER_PLUS_EXPR,
TREE_TYPE (dest), dest, len);
}
+ else
+ gcc_unreachable ();
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
gimple *repl = gimple_build_assign (lhs, dest);
@@ -3848,14 +3847,10 @@ gimple_fold_builtin (gimple_stmt_iterator *gsi)
gimple_call_arg (stmt, 1),
gimple_call_arg (stmt, 2));
case BUILT_IN_MEMCPY:
- return gimple_fold_builtin_memory_op (gsi, gimple_call_arg (stmt, 0),
- gimple_call_arg (stmt, 1), 0);
case BUILT_IN_MEMPCPY:
- return gimple_fold_builtin_memory_op (gsi, gimple_call_arg (stmt, 0),
- gimple_call_arg (stmt, 1), 1);
case BUILT_IN_MEMMOVE:
return gimple_fold_builtin_memory_op (gsi, gimple_call_arg (stmt, 0),
- gimple_call_arg (stmt, 1), 3);
+ gimple_call_arg (stmt, 1), fcode);
case BUILT_IN_SPRINTF_CHK:
case BUILT_IN_VSPRINTF_CHK:
return gimple_fold_builtin_sprintf_chk (gsi, fcode);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][stage1] Refactor gimple_fold_builtin_memory_op function.
2019-03-12 9:26 [PATCH][stage1] Refactor gimple_fold_builtin_memory_op function Martin Liška
@ 2019-04-29 20:29 ` Jeff Law
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2019-04-29 20:29 UTC (permalink / raw)
To: Martin Liška, gcc-patches
On 3/12/19 2:45 AM, Martin Liška wrote:
> Hi.
>
> The patch is about simplification and usage of enum types. ENDP integer
> does not make much sense in this usage.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed after stage1 opens?
> Thanks,
> Martin
>
> 2019-03-11 Martin Liska <mliska@suse.cz>
>
> * gimple-fold.c (gimple_fold_builtin_memory_op): Change endp
> into built_in_function enum. Remove code for endp == 2 and
> use BUILT_IN_* constants.
> (gimple_fold_builtin): Call the function with fcode.
OK
jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-29 20:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-12 9:26 [PATCH][stage1] Refactor gimple_fold_builtin_memory_op function Martin Liška
2019-04-29 20:29 ` Jeff Law
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).