* gcc.dg/vect/slp-9.c: Disable einline.
[official-gcc.git] / gcc / gimple-match-head.c
blobd708132e5716891d8f3a42b0b1a4b2e59dbf15d3
1 /* Preamble and helpers for the autogenerated gimple-match.c file.
2 Copyright (C) 2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #include "config.h"
21 #include "system.h"
22 #include "coretypes.h"
23 #include "tree.h"
24 #include "stringpool.h"
25 #include "stor-layout.h"
26 #include "flags.h"
27 #include "tm.h"
28 #include "hard-reg-set.h"
29 #include "function.h"
30 #include "predict.h"
31 #include "vec.h"
32 #include "hashtab.h"
33 #include "hash-set.h"
34 #include "machmode.h"
35 #include "input.h"
36 #include "basic-block.h"
37 #include "tree-ssa-alias.h"
38 #include "internal-fn.h"
39 #include "gimple-expr.h"
40 #include "is-a.h"
41 #include "gimple.h"
42 #include "gimple-ssa.h"
43 #include "tree-ssanames.h"
44 #include "gimple-fold.h"
45 #include "gimple-iterator.h"
46 #include "expr.h"
47 #include "tree-dfa.h"
48 #include "builtins.h"
49 #include "tree-phinodes.h"
50 #include "ssa-iterators.h"
51 #include "dumpfile.h"
52 #include "gimple-match.h"
55 /* Forward declarations of the private auto-generated matchers.
56 They expect valueized operands in canonical order and do not
57 perform simplification of all-constant operands. */
58 static bool gimple_simplify (code_helper *, tree *,
59 gimple_seq *, tree (*)(tree),
60 code_helper, tree, tree);
61 static bool gimple_simplify (code_helper *, tree *,
62 gimple_seq *, tree (*)(tree),
63 code_helper, tree, tree, tree);
64 static bool gimple_simplify (code_helper *, tree *,
65 gimple_seq *, tree (*)(tree),
66 code_helper, tree, tree, tree, tree);
69 /* Return whether T is a constant that we'll dispatch to fold to
70 evaluate fully constant expressions. */
72 static inline bool
73 constant_for_folding (tree t)
75 return (CONSTANT_CLASS_P (t)
76 /* The following is only interesting to string builtins. */
77 || (TREE_CODE (t) == ADDR_EXPR
78 && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST));
82 /* Helper that matches and simplifies the toplevel result from
83 a gimple_simplify run (where we don't want to build
84 a stmt in case it's used in in-place folding). Replaces
85 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
86 result and returns whether any change was made. */
88 static bool
89 gimple_resimplify1 (gimple_seq *seq,
90 code_helper *res_code, tree type, tree *res_ops,
91 tree (*valueize)(tree))
93 if (constant_for_folding (res_ops[0]))
95 tree tem = NULL_TREE;
96 if (res_code->is_tree_code ())
97 tem = const_unop (*res_code, type, res_ops[0]);
98 else
100 tree decl = builtin_decl_implicit (*res_code);
101 if (decl)
103 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 1, false);
104 if (tem)
106 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
107 STRIP_NOPS (tem);
108 tem = fold_convert (type, tem);
112 if (tem != NULL_TREE
113 && CONSTANT_CLASS_P (tem))
115 res_ops[0] = tem;
116 res_ops[1] = NULL_TREE;
117 res_ops[2] = NULL_TREE;
118 *res_code = TREE_CODE (res_ops[0]);
119 return true;
123 code_helper res_code2;
124 tree res_ops2[3] = {};
125 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
126 *res_code, type, res_ops[0]))
128 *res_code = res_code2;
129 res_ops[0] = res_ops2[0];
130 res_ops[1] = res_ops2[1];
131 res_ops[2] = res_ops2[2];
132 return true;
135 return false;
138 /* Helper that matches and simplifies the toplevel result from
139 a gimple_simplify run (where we don't want to build
140 a stmt in case it's used in in-place folding). Replaces
141 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
142 result and returns whether any change was made. */
144 static bool
145 gimple_resimplify2 (gimple_seq *seq,
146 code_helper *res_code, tree type, tree *res_ops,
147 tree (*valueize)(tree))
149 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1]))
151 tree tem = NULL_TREE;
152 if (res_code->is_tree_code ())
153 tem = const_binop (*res_code, type, res_ops[0], res_ops[1]);
154 else
156 tree decl = builtin_decl_implicit (*res_code);
157 if (decl)
159 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 2, false);
160 if (tem)
162 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
163 STRIP_NOPS (tem);
164 tem = fold_convert (type, tem);
168 if (tem != NULL_TREE
169 && CONSTANT_CLASS_P (tem))
171 res_ops[0] = tem;
172 res_ops[1] = NULL_TREE;
173 res_ops[2] = NULL_TREE;
174 *res_code = TREE_CODE (res_ops[0]);
175 return true;
179 /* Canonicalize operand order. */
180 bool canonicalized = false;
181 if (res_code->is_tree_code ()
182 && (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison
183 || commutative_tree_code (*res_code))
184 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
186 tree tem = res_ops[0];
187 res_ops[0] = res_ops[1];
188 res_ops[1] = tem;
189 if (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison)
190 *res_code = swap_tree_comparison (*res_code);
191 canonicalized = true;
194 code_helper res_code2;
195 tree res_ops2[3] = {};
196 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
197 *res_code, type, res_ops[0], res_ops[1]))
199 *res_code = res_code2;
200 res_ops[0] = res_ops2[0];
201 res_ops[1] = res_ops2[1];
202 res_ops[2] = res_ops2[2];
203 return true;
206 return canonicalized;
209 /* Helper that matches and simplifies the toplevel result from
210 a gimple_simplify run (where we don't want to build
211 a stmt in case it's used in in-place folding). Replaces
212 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
213 result and returns whether any change was made. */
215 static bool
216 gimple_resimplify3 (gimple_seq *seq,
217 code_helper *res_code, tree type, tree *res_ops,
218 tree (*valueize)(tree))
220 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1])
221 && constant_for_folding (res_ops[2]))
223 tree tem = NULL_TREE;
224 if (res_code->is_tree_code ())
225 tem = fold_ternary/*_to_constant*/ (*res_code, type, res_ops[0],
226 res_ops[1], res_ops[2]);
227 else
229 tree decl = builtin_decl_implicit (*res_code);
230 if (decl)
232 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 3, false);
233 if (tem)
235 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
236 STRIP_NOPS (tem);
237 tem = fold_convert (type, tem);
241 if (tem != NULL_TREE
242 && CONSTANT_CLASS_P (tem))
244 res_ops[0] = tem;
245 res_ops[1] = NULL_TREE;
246 res_ops[2] = NULL_TREE;
247 *res_code = TREE_CODE (res_ops[0]);
248 return true;
252 /* Canonicalize operand order. */
253 bool canonicalized = false;
254 if (res_code->is_tree_code ()
255 && commutative_ternary_tree_code (*res_code)
256 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
258 tree tem = res_ops[0];
259 res_ops[0] = res_ops[1];
260 res_ops[1] = tem;
261 canonicalized = true;
264 code_helper res_code2;
265 tree res_ops2[3] = {};
266 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
267 *res_code, type,
268 res_ops[0], res_ops[1], res_ops[2]))
270 *res_code = res_code2;
271 res_ops[0] = res_ops2[0];
272 res_ops[1] = res_ops2[1];
273 res_ops[2] = res_ops2[2];
274 return true;
277 return canonicalized;
281 /* If in GIMPLE expressions with CODE go as single-rhs build
282 a GENERIC tree for that expression into *OP0. */
284 void
285 maybe_build_generic_op (enum tree_code code, tree type,
286 tree *op0, tree op1, tree op2)
288 switch (code)
290 case REALPART_EXPR:
291 case IMAGPART_EXPR:
292 case VIEW_CONVERT_EXPR:
293 *op0 = build1 (code, type, *op0);
294 break;
295 case BIT_FIELD_REF:
296 *op0 = build3 (code, type, *op0, op1, op2);
297 break;
298 default:;
302 /* Push the exploded expression described by RCODE, TYPE and OPS
303 as a statement to SEQ if necessary and return a gimple value
304 denoting the value of the expression. If RES is not NULL
305 then the result will be always RES and even gimple values are
306 pushed to SEQ. */
308 tree
309 maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
310 gimple_seq *seq, tree res)
312 if (rcode.is_tree_code ())
314 if (!res
315 && (TREE_CODE_LENGTH ((tree_code) rcode) == 0
316 || ((tree_code) rcode) == ADDR_EXPR)
317 && is_gimple_val (ops[0]))
318 return ops[0];
319 if (!seq)
320 return NULL_TREE;
321 /* Play safe and do not allow abnormals to be mentioned in
322 newly created statements. */
323 if ((TREE_CODE (ops[0]) == SSA_NAME
324 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
325 || (ops[1]
326 && TREE_CODE (ops[1]) == SSA_NAME
327 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
328 || (ops[2]
329 && TREE_CODE (ops[2]) == SSA_NAME
330 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
331 return NULL_TREE;
332 if (!res)
333 res = make_ssa_name (type);
334 maybe_build_generic_op (rcode, type, &ops[0], ops[1], ops[2]);
335 gimple new_stmt = gimple_build_assign (res, rcode,
336 ops[0], ops[1], ops[2]);
337 gimple_seq_add_stmt_without_update (seq, new_stmt);
338 return res;
340 else
342 if (!seq)
343 return NULL_TREE;
344 tree decl = builtin_decl_implicit (rcode);
345 if (!decl)
346 return NULL_TREE;
347 unsigned nargs = type_num_arguments (TREE_TYPE (decl));
348 gcc_assert (nargs <= 3);
349 /* Play safe and do not allow abnormals to be mentioned in
350 newly created statements. */
351 if ((TREE_CODE (ops[0]) == SSA_NAME
352 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
353 || (nargs >= 2
354 && TREE_CODE (ops[1]) == SSA_NAME
355 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
356 || (nargs == 3
357 && TREE_CODE (ops[2]) == SSA_NAME
358 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
359 return NULL_TREE;
360 if (!res)
361 res = make_ssa_name (type);
362 gimple new_stmt = gimple_build_call (decl, nargs, ops[0], ops[1], ops[2]);
363 gimple_call_set_lhs (new_stmt, res);
364 gimple_seq_add_stmt_without_update (seq, new_stmt);
365 return res;
370 /* Public API overloads follow for operation being tree_code or
371 built_in_function and for one to three operands or arguments.
372 They return NULL_TREE if nothing could be simplified or
373 the resulting simplified value with parts pushed to SEQ.
374 If SEQ is NULL then if the simplification needs to create
375 new stmts it will fail. If VALUEIZE is non-NULL then all
376 SSA names will be valueized using that hook prior to
377 applying simplifications. */
379 /* Unary ops. */
381 tree
382 gimple_simplify (enum tree_code code, tree type,
383 tree op0,
384 gimple_seq *seq, tree (*valueize)(tree))
386 if (constant_for_folding (op0))
388 tree res = const_unop (code, type, op0);
389 if (res != NULL_TREE
390 && CONSTANT_CLASS_P (res))
391 return res;
394 code_helper rcode;
395 tree ops[3] = {};
396 if (!gimple_simplify (&rcode, ops, seq, valueize,
397 code, type, op0))
398 return NULL_TREE;
399 return maybe_push_res_to_seq (rcode, type, ops, seq);
402 /* Binary ops. */
404 tree
405 gimple_simplify (enum tree_code code, tree type,
406 tree op0, tree op1,
407 gimple_seq *seq, tree (*valueize)(tree))
409 if (constant_for_folding (op0) && constant_for_folding (op1))
411 tree res = const_binop (code, type, op0, op1);
412 if (res != NULL_TREE
413 && CONSTANT_CLASS_P (res))
414 return res;
417 /* Canonicalize operand order both for matching and fallback stmt
418 generation. */
419 if ((commutative_tree_code (code)
420 || TREE_CODE_CLASS (code) == tcc_comparison)
421 && tree_swap_operands_p (op0, op1, false))
423 tree tem = op0;
424 op0 = op1;
425 op1 = tem;
426 if (TREE_CODE_CLASS (code) == tcc_comparison)
427 code = swap_tree_comparison (code);
430 code_helper rcode;
431 tree ops[3] = {};
432 if (!gimple_simplify (&rcode, ops, seq, valueize,
433 code, type, op0, op1))
434 return NULL_TREE;
435 return maybe_push_res_to_seq (rcode, type, ops, seq);
438 /* Ternary ops. */
440 tree
441 gimple_simplify (enum tree_code code, tree type,
442 tree op0, tree op1, tree op2,
443 gimple_seq *seq, tree (*valueize)(tree))
445 if (constant_for_folding (op0) && constant_for_folding (op1)
446 && constant_for_folding (op2))
448 tree res = fold_ternary/*_to_constant */ (code, type, op0, op1, op2);
449 if (res != NULL_TREE
450 && CONSTANT_CLASS_P (res))
451 return res;
454 /* Canonicalize operand order both for matching and fallback stmt
455 generation. */
456 if (commutative_ternary_tree_code (code)
457 && tree_swap_operands_p (op0, op1, false))
459 tree tem = op0;
460 op0 = op1;
461 op1 = tem;
464 code_helper rcode;
465 tree ops[3] = {};
466 if (!gimple_simplify (&rcode, ops, seq, valueize,
467 code, type, op0, op1, op2))
468 return NULL_TREE;
469 return maybe_push_res_to_seq (rcode, type, ops, seq);
472 /* Builtin function with one argument. */
474 tree
475 gimple_simplify (enum built_in_function fn, tree type,
476 tree arg0,
477 gimple_seq *seq, tree (*valueize)(tree))
479 if (constant_for_folding (arg0))
481 tree decl = builtin_decl_implicit (fn);
482 if (decl)
484 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, &arg0, 1, false);
485 if (res)
487 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
488 STRIP_NOPS (res);
489 res = fold_convert (type, res);
490 if (CONSTANT_CLASS_P (res))
491 return res;
496 code_helper rcode;
497 tree ops[3] = {};
498 if (!gimple_simplify (&rcode, ops, seq, valueize,
499 fn, type, arg0))
500 return NULL_TREE;
501 return maybe_push_res_to_seq (rcode, type, ops, seq);
504 /* Builtin function with two arguments. */
506 tree
507 gimple_simplify (enum built_in_function fn, tree type,
508 tree arg0, tree arg1,
509 gimple_seq *seq, tree (*valueize)(tree))
511 if (constant_for_folding (arg0)
512 && constant_for_folding (arg1))
514 tree decl = builtin_decl_implicit (fn);
515 if (decl)
517 tree args[2];
518 args[0] = arg0;
519 args[1] = arg1;
520 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 2, false);
521 if (res)
523 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
524 STRIP_NOPS (res);
525 res = fold_convert (type, res);
526 if (CONSTANT_CLASS_P (res))
527 return res;
532 code_helper rcode;
533 tree ops[3] = {};
534 if (!gimple_simplify (&rcode, ops, seq, valueize,
535 fn, type, arg0, arg1))
536 return NULL_TREE;
537 return maybe_push_res_to_seq (rcode, type, ops, seq);
540 /* Builtin function with three arguments. */
542 tree
543 gimple_simplify (enum built_in_function fn, tree type,
544 tree arg0, tree arg1, tree arg2,
545 gimple_seq *seq, tree (*valueize)(tree))
547 if (constant_for_folding (arg0)
548 && constant_for_folding (arg1)
549 && constant_for_folding (arg2))
551 tree decl = builtin_decl_implicit (fn);
552 if (decl)
554 tree args[3];
555 args[0] = arg0;
556 args[1] = arg1;
557 args[2] = arg2;
558 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 3, false);
559 if (res)
561 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
562 STRIP_NOPS (res);
563 res = fold_convert (type, res);
564 if (CONSTANT_CLASS_P (res))
565 return res;
570 code_helper rcode;
571 tree ops[3] = {};
572 if (!gimple_simplify (&rcode, ops, seq, valueize,
573 fn, type, arg0, arg1, arg2))
574 return NULL_TREE;
575 return maybe_push_res_to_seq (rcode, type, ops, seq);
579 /* The main STMT based simplification entry. It is used by the fold_stmt
580 and the fold_stmt_to_constant APIs. */
582 bool
583 gimple_simplify (gimple stmt,
584 code_helper *rcode, tree *ops,
585 gimple_seq *seq, tree (*valueize)(tree))
587 switch (gimple_code (stmt))
589 case GIMPLE_ASSIGN:
591 enum tree_code code = gimple_assign_rhs_code (stmt);
592 tree type = TREE_TYPE (gimple_assign_lhs (stmt));
593 switch (gimple_assign_rhs_class (stmt))
595 case GIMPLE_SINGLE_RHS:
596 if (code == REALPART_EXPR
597 || code == IMAGPART_EXPR
598 || code == VIEW_CONVERT_EXPR)
600 tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
601 if (valueize && TREE_CODE (op0) == SSA_NAME)
603 tree tem = valueize (op0);
604 if (tem)
605 op0 = tem;
607 *rcode = code;
608 ops[0] = op0;
609 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
611 else if (code == BIT_FIELD_REF)
613 tree rhs1 = gimple_assign_rhs1 (stmt);
614 tree op0 = TREE_OPERAND (rhs1, 0);
615 if (valueize && TREE_CODE (op0) == SSA_NAME)
617 tree tem = valueize (op0);
618 if (tem)
619 op0 = tem;
621 *rcode = code;
622 ops[0] = op0;
623 ops[1] = TREE_OPERAND (rhs1, 1);
624 ops[2] = TREE_OPERAND (rhs1, 2);
625 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
627 else if (code == SSA_NAME
628 && valueize)
630 tree op0 = gimple_assign_rhs1 (stmt);
631 tree valueized = valueize (op0);
632 if (!valueized || op0 == valueized)
633 return false;
634 ops[0] = valueized;
635 *rcode = TREE_CODE (op0);
636 return true;
638 break;
639 case GIMPLE_UNARY_RHS:
641 tree rhs1 = gimple_assign_rhs1 (stmt);
642 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
644 tree tem = valueize (rhs1);
645 if (tem)
646 rhs1 = tem;
648 *rcode = code;
649 ops[0] = rhs1;
650 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
652 case GIMPLE_BINARY_RHS:
654 tree rhs1 = gimple_assign_rhs1 (stmt);
655 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
657 tree tem = valueize (rhs1);
658 if (tem)
659 rhs1 = tem;
661 tree rhs2 = gimple_assign_rhs2 (stmt);
662 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
664 tree tem = valueize (rhs2);
665 if (tem)
666 rhs2 = tem;
668 *rcode = code;
669 ops[0] = rhs1;
670 ops[1] = rhs2;
671 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
673 case GIMPLE_TERNARY_RHS:
675 tree rhs1 = gimple_assign_rhs1 (stmt);
676 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
678 tree tem = valueize (rhs1);
679 if (tem)
680 rhs1 = tem;
682 tree rhs2 = gimple_assign_rhs2 (stmt);
683 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
685 tree tem = valueize (rhs2);
686 if (tem)
687 rhs2 = tem;
689 tree rhs3 = gimple_assign_rhs3 (stmt);
690 if (valueize && TREE_CODE (rhs3) == SSA_NAME)
692 tree tem = valueize (rhs3);
693 if (tem)
694 rhs3 = tem;
696 *rcode = code;
697 ops[0] = rhs1;
698 ops[1] = rhs2;
699 ops[2] = rhs3;
700 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
702 default:
703 gcc_unreachable ();
705 break;
708 case GIMPLE_CALL:
709 /* ??? This way we can't simplify calls with side-effects. */
710 if (gimple_call_lhs (stmt) != NULL_TREE)
712 tree fn = gimple_call_fn (stmt);
713 /* ??? Internal function support missing. */
714 if (!fn)
715 return false;
716 if (valueize && TREE_CODE (fn) == SSA_NAME)
718 tree tem = valueize (fn);
719 if (tem)
720 fn = tem;
722 if (!fn
723 || TREE_CODE (fn) != ADDR_EXPR
724 || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL
725 || DECL_BUILT_IN_CLASS (TREE_OPERAND (fn, 0)) != BUILT_IN_NORMAL
726 || !builtin_decl_implicit (DECL_FUNCTION_CODE (TREE_OPERAND (fn, 0)))
727 || !gimple_builtin_call_types_compatible_p (stmt,
728 TREE_OPERAND (fn, 0)))
729 return false;
731 tree decl = TREE_OPERAND (fn, 0);
732 tree type = TREE_TYPE (gimple_call_lhs (stmt));
733 switch (gimple_call_num_args (stmt))
735 case 1:
737 tree arg1 = gimple_call_arg (stmt, 0);
738 if (valueize && TREE_CODE (arg1) == SSA_NAME)
740 tree tem = valueize (arg1);
741 if (tem)
742 arg1 = tem;
744 *rcode = DECL_FUNCTION_CODE (decl);
745 ops[0] = arg1;
746 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
748 case 2:
750 tree arg1 = gimple_call_arg (stmt, 0);
751 if (valueize && TREE_CODE (arg1) == SSA_NAME)
753 tree tem = valueize (arg1);
754 if (tem)
755 arg1 = tem;
757 tree arg2 = gimple_call_arg (stmt, 1);
758 if (valueize && TREE_CODE (arg2) == SSA_NAME)
760 tree tem = valueize (arg2);
761 if (tem)
762 arg2 = tem;
764 *rcode = DECL_FUNCTION_CODE (decl);
765 ops[0] = arg1;
766 ops[1] = arg2;
767 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
769 case 3:
771 tree arg1 = gimple_call_arg (stmt, 0);
772 if (valueize && TREE_CODE (arg1) == SSA_NAME)
774 tree tem = valueize (arg1);
775 if (tem)
776 arg1 = tem;
778 tree arg2 = gimple_call_arg (stmt, 1);
779 if (valueize && TREE_CODE (arg2) == SSA_NAME)
781 tree tem = valueize (arg2);
782 if (tem)
783 arg2 = tem;
785 tree arg3 = gimple_call_arg (stmt, 2);
786 if (valueize && TREE_CODE (arg3) == SSA_NAME)
788 tree tem = valueize (arg3);
789 if (tem)
790 arg3 = tem;
792 *rcode = DECL_FUNCTION_CODE (decl);
793 ops[0] = arg1;
794 ops[1] = arg2;
795 ops[2] = arg3;
796 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
798 default:
799 return false;
802 break;
804 case GIMPLE_COND:
806 tree lhs = gimple_cond_lhs (stmt);
807 if (valueize && TREE_CODE (lhs) == SSA_NAME)
809 tree tem = valueize (lhs);
810 if (tem)
811 lhs = tem;
813 tree rhs = gimple_cond_rhs (stmt);
814 if (valueize && TREE_CODE (rhs) == SSA_NAME)
816 tree tem = valueize (rhs);
817 if (tem)
818 rhs = tem;
820 *rcode = gimple_cond_code (stmt);
821 ops[0] = lhs;
822 ops[1] = rhs;
823 return gimple_resimplify2 (seq, rcode, boolean_type_node, ops, valueize);
826 default:
827 break;
830 return false;
834 /* Helper for the autogenerated code, valueize OP. */
836 inline tree
837 do_valueize (tree (*valueize)(tree), tree op)
839 if (valueize && TREE_CODE (op) == SSA_NAME)
840 return valueize (op);
841 return op;