On Fri, Oct 7, 2016 at 10:41 AM, Martin Liška <[email protected]> wrote:
> Resending the patch, where I implemented folding in gimple-fold.c
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
+/* Fold a call to the str{n}{case}cmp builtin pointed by GSI iterator.
+ FCODE is the name of the builtin. */
wrong comment
+static bool
+gimple_fold_builtin_memchr (gimple_stmt_iterator *gsi)
+ {
+ replace_call_with_value (gsi, build_int_cst (type, 0));
use ptr_type_node (void *) instead of type here and below.
+ HOST_WIDE_INT offset = r - p1;
+ if (compare_tree_int (len, offset) <= 0)
+ {
== 0 can occur in which case we have to return a pointer to the
first char. I think len < offset can't happen with memchr?
+ replace_call_with_value (gsi, build_int_cst (type, 0));
+ return true;
+ }
+ else
+ {
+ tree temp = fold_build_pointer_plus_hwi_loc (loc, arg1, offset);
+ replace_call_with_value (gsi, temp);
That yields valid GIMPLE by chance, I'd prefer if you'd built that to a
stmt and use the replace-with-vops.
+ return true;
+ }
> Ready to be installed?
> Martin