$subject, applied. Richard.
2014-08-06 Richard Biener <rguent...@suse.de> * gimple-fold.h (gimple_simplify): Add two-parameter builtin function overload. * gimple-match-head.c (gimple_simplify): Implement it. Index: gcc/gimple-fold.h =================================================================== --- gcc/gimple-fold.h (revision 213651) +++ gcc/gimple-fold.h (working copy) @@ -117,6 +117,8 @@ tree gimple_simplify (enum tree_code, tr gimple_seq *, tree (*)(tree)); tree gimple_simplify (enum built_in_function, tree, tree, gimple_seq *, tree (*)(tree)); +tree gimple_simplify (enum built_in_function, tree, tree, tree, + gimple_seq *, tree (*)(tree)); /* The following two APIs are an artifact and should vanish in favor of the existing gimple_fold_stmt_to_constant and fold_stmt APIs. */ tree gimple_simplify (tree, gimple_seq *, tree (*)(tree)); Index: gcc/gimple-match-head.c =================================================================== --- gcc/gimple-match-head.c (revision 213655) +++ gcc/gimple-match-head.c (working copy) @@ -464,6 +464,37 @@ gimple_simplify (enum built_in_function return maybe_push_res_to_seq (rcode, type, ops, seq); } +tree +gimple_simplify (enum built_in_function fn, tree type, + tree arg0, tree arg1, + gimple_seq *seq, tree (*valueize)(tree)) +{ + if (constant_for_folding (arg0) + && constant_for_folding (arg1)) + { + tree decl = builtin_decl_implicit (fn); + if (decl) + { + tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, &arg0, 2, false); + if (res) + { + /* fold_builtin_n wraps the result inside a NOP_EXPR. */ + STRIP_NOPS (res); + res = fold_convert (type, res); + if (CONSTANT_CLASS_P (res)) + return res; + } + } + } + + code_helper rcode; + tree ops[3] = {}; + if (!gimple_simplify (&rcode, ops, seq, valueize, + fn, type, arg0, arg1)) + return NULL_TREE; + return maybe_push_res_to_seq (rcode, type, ops, seq); +} + static bool gimple_simplify (gimple stmt, code_helper *rcode, tree *ops,