2014-10-24 Christophe Lyon <christophe.lyon@linaro.org>
[official-gcc.git] / gcc / gimple-match-head.c
blob0558e9a892e2fa1a6b7981caf63e2f169ea9b79f
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 "basic-block.h"
31 #include "tree-ssa-alias.h"
32 #include "internal-fn.h"
33 #include "gimple-expr.h"
34 #include "is-a.h"
35 #include "gimple.h"
36 #include "gimple-ssa.h"
37 #include "tree-ssanames.h"
38 #include "gimple-fold.h"
39 #include "gimple-iterator.h"
40 #include "expr.h"
41 #include "tree-dfa.h"
42 #include "builtins.h"
43 #include "tree-phinodes.h"
44 #include "ssa-iterators.h"
45 #include "dumpfile.h"
46 #include "gimple-match.h"
49 /* Forward declarations of the private auto-generated matchers.
50 They expect valueized operands in canonical order and do not
51 perform simplification of all-constant operands. */
52 static bool gimple_simplify (code_helper *, tree *,
53 gimple_seq *, tree (*)(tree),
54 code_helper, tree, tree);
55 static bool gimple_simplify (code_helper *, tree *,
56 gimple_seq *, tree (*)(tree),
57 code_helper, tree, tree, tree);
58 static bool gimple_simplify (code_helper *, tree *,
59 gimple_seq *, tree (*)(tree),
60 code_helper, tree, tree, tree, tree);
63 /* Return whether T is a constant that we'll dispatch to fold to
64 evaluate fully constant expressions. */
66 static inline bool
67 constant_for_folding (tree t)
69 return (CONSTANT_CLASS_P (t)
70 /* The following is only interesting to string builtins. */
71 || (TREE_CODE (t) == ADDR_EXPR
72 && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST));
76 /* Helper that matches and simplifies the toplevel result from
77 a gimple_simplify run (where we don't want to build
78 a stmt in case it's used in in-place folding). Replaces
79 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
80 result and returns whether any change was made. */
82 static bool
83 gimple_resimplify1 (gimple_seq *seq,
84 code_helper *res_code, tree type, tree *res_ops,
85 tree (*valueize)(tree))
87 if (constant_for_folding (res_ops[0]))
89 tree tem = NULL_TREE;
90 if (res_code->is_tree_code ())
91 tem = fold_unary_to_constant (*res_code, type, res_ops[0]);
92 else
94 tree decl = builtin_decl_implicit (*res_code);
95 if (decl)
97 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 1, false);
98 if (tem)
100 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
101 STRIP_NOPS (tem);
102 tem = fold_convert (type, tem);
106 if (tem != NULL_TREE
107 && CONSTANT_CLASS_P (tem))
109 res_ops[0] = tem;
110 res_ops[1] = NULL_TREE;
111 res_ops[2] = NULL_TREE;
112 *res_code = TREE_CODE (res_ops[0]);
113 return true;
117 code_helper res_code2;
118 tree res_ops2[3] = {};
119 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
120 *res_code, type, res_ops[0]))
122 *res_code = res_code2;
123 res_ops[0] = res_ops2[0];
124 res_ops[1] = res_ops2[1];
125 res_ops[2] = res_ops2[2];
126 return true;
129 return false;
132 /* Helper that matches and simplifies the toplevel result from
133 a gimple_simplify run (where we don't want to build
134 a stmt in case it's used in in-place folding). Replaces
135 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
136 result and returns whether any change was made. */
138 static bool
139 gimple_resimplify2 (gimple_seq *seq,
140 code_helper *res_code, tree type, tree *res_ops,
141 tree (*valueize)(tree))
143 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1]))
145 tree tem = NULL_TREE;
146 if (res_code->is_tree_code ())
147 tem = fold_binary_to_constant (*res_code, type,
148 res_ops[0], res_ops[1]);
149 else
151 tree decl = builtin_decl_implicit (*res_code);
152 if (decl)
154 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 2, false);
155 if (tem)
157 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
158 STRIP_NOPS (tem);
159 tem = fold_convert (type, tem);
163 if (tem != NULL_TREE
164 && CONSTANT_CLASS_P (tem))
166 res_ops[0] = tem;
167 res_ops[1] = NULL_TREE;
168 res_ops[2] = NULL_TREE;
169 *res_code = TREE_CODE (res_ops[0]);
170 return true;
174 /* Canonicalize operand order. */
175 bool canonicalized = false;
176 if (res_code->is_tree_code ()
177 && (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison
178 || commutative_tree_code (*res_code))
179 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
181 tree tem = res_ops[0];
182 res_ops[0] = res_ops[1];
183 res_ops[1] = tem;
184 if (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison)
185 *res_code = swap_tree_comparison (*res_code);
186 canonicalized = true;
189 code_helper res_code2;
190 tree res_ops2[3] = {};
191 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
192 *res_code, type, res_ops[0], res_ops[1]))
194 *res_code = res_code2;
195 res_ops[0] = res_ops2[0];
196 res_ops[1] = res_ops2[1];
197 res_ops[2] = res_ops2[2];
198 return true;
201 return canonicalized;
204 /* Helper that matches and simplifies the toplevel result from
205 a gimple_simplify run (where we don't want to build
206 a stmt in case it's used in in-place folding). Replaces
207 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
208 result and returns whether any change was made. */
210 static bool
211 gimple_resimplify3 (gimple_seq *seq,
212 code_helper *res_code, tree type, tree *res_ops,
213 tree (*valueize)(tree))
215 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1])
216 && constant_for_folding (res_ops[2]))
218 tree tem = NULL_TREE;
219 if (res_code->is_tree_code ())
220 tem = fold_ternary/*_to_constant*/ (*res_code, type, res_ops[0],
221 res_ops[1], res_ops[2]);
222 else
224 tree decl = builtin_decl_implicit (*res_code);
225 if (decl)
227 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 3, false);
228 if (tem)
230 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
231 STRIP_NOPS (tem);
232 tem = fold_convert (type, tem);
236 if (tem != NULL_TREE
237 && CONSTANT_CLASS_P (tem))
239 res_ops[0] = tem;
240 res_ops[1] = NULL_TREE;
241 res_ops[2] = NULL_TREE;
242 *res_code = TREE_CODE (res_ops[0]);
243 return true;
247 /* Canonicalize operand order. */
248 bool canonicalized = false;
249 if (res_code->is_tree_code ()
250 && commutative_ternary_tree_code (*res_code)
251 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
253 tree tem = res_ops[0];
254 res_ops[0] = res_ops[1];
255 res_ops[1] = tem;
256 canonicalized = true;
259 code_helper res_code2;
260 tree res_ops2[3] = {};
261 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
262 *res_code, type,
263 res_ops[0], res_ops[1], res_ops[2]))
265 *res_code = res_code2;
266 res_ops[0] = res_ops2[0];
267 res_ops[1] = res_ops2[1];
268 res_ops[2] = res_ops2[2];
269 return true;
272 return canonicalized;
276 /* If in GIMPLE expressions with CODE go as single-rhs build
277 a GENERIC tree for that expression into *OP0. */
279 void
280 maybe_build_generic_op (enum tree_code code, tree type,
281 tree *op0, tree op1, tree op2)
283 switch (code)
285 case REALPART_EXPR:
286 case IMAGPART_EXPR:
287 case VIEW_CONVERT_EXPR:
288 *op0 = build1 (code, type, *op0);
289 break;
290 case BIT_FIELD_REF:
291 *op0 = build3 (code, type, *op0, op1, op2);
292 break;
293 default:;
297 /* Push the exploded expression described by RCODE, TYPE and OPS
298 as a statement to SEQ if necessary and return a gimple value
299 denoting the value of the expression. If RES is not NULL
300 then the result will be always RES and even gimple values are
301 pushed to SEQ. */
303 tree
304 maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
305 gimple_seq *seq, tree res)
307 if (rcode.is_tree_code ())
309 if (!res
310 && (TREE_CODE_LENGTH ((tree_code) rcode) == 0
311 || ((tree_code) rcode) == ADDR_EXPR)
312 && is_gimple_val (ops[0]))
313 return ops[0];
314 if (!seq)
315 return NULL_TREE;
316 /* Play safe and do not allow abnormals to be mentioned in
317 newly created statements. */
318 if ((TREE_CODE (ops[0]) == SSA_NAME
319 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
320 || (ops[1]
321 && TREE_CODE (ops[1]) == SSA_NAME
322 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
323 || (ops[2]
324 && TREE_CODE (ops[2]) == SSA_NAME
325 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
326 return NULL_TREE;
327 if (!res)
328 res = make_ssa_name (type, NULL);
329 maybe_build_generic_op (rcode, type, &ops[0], ops[1], ops[2]);
330 gimple new_stmt = gimple_build_assign_with_ops (rcode, res,
331 ops[0], ops[1], ops[2]);
332 gimple_seq_add_stmt_without_update (seq, new_stmt);
333 return res;
335 else
337 if (!seq)
338 return NULL_TREE;
339 tree decl = builtin_decl_implicit (rcode);
340 if (!decl)
341 return NULL_TREE;
342 unsigned nargs = type_num_arguments (TREE_TYPE (decl));
343 gcc_assert (nargs <= 3);
344 /* Play safe and do not allow abnormals to be mentioned in
345 newly created statements. */
346 if ((TREE_CODE (ops[0]) == SSA_NAME
347 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
348 || (nargs >= 2
349 && TREE_CODE (ops[1]) == SSA_NAME
350 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
351 || (nargs == 3
352 && TREE_CODE (ops[2]) == SSA_NAME
353 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
354 return NULL_TREE;
355 if (!res)
356 res = make_ssa_name (type, NULL);
357 gimple new_stmt = gimple_build_call (decl, nargs, ops[0], ops[1], ops[2]);
358 gimple_call_set_lhs (new_stmt, res);
359 gimple_seq_add_stmt_without_update (seq, new_stmt);
360 return res;
365 /* Public API overloads follow for operation being tree_code or
366 built_in_function and for one to three operands or arguments.
367 They return NULL_TREE if nothing could be simplified or
368 the resulting simplified value with parts pushed to SEQ.
369 If SEQ is NULL then if the simplification needs to create
370 new stmts it will fail. If VALUEIZE is non-NULL then all
371 SSA names will be valueized using that hook prior to
372 applying simplifications. */
374 /* Unary ops. */
376 tree
377 gimple_simplify (enum tree_code code, tree type,
378 tree op0,
379 gimple_seq *seq, tree (*valueize)(tree))
381 if (constant_for_folding (op0))
383 tree res = fold_unary_to_constant (code, type, op0);
384 if (res != NULL_TREE
385 && CONSTANT_CLASS_P (res))
386 return res;
389 code_helper rcode;
390 tree ops[3] = {};
391 if (!gimple_simplify (&rcode, ops, seq, valueize,
392 code, type, op0))
393 return NULL_TREE;
394 return maybe_push_res_to_seq (rcode, type, ops, seq);
397 /* Binary ops. */
399 tree
400 gimple_simplify (enum tree_code code, tree type,
401 tree op0, tree op1,
402 gimple_seq *seq, tree (*valueize)(tree))
404 if (constant_for_folding (op0) && constant_for_folding (op1))
406 tree res = fold_binary_to_constant (code, type, op0, op1);
407 if (res != NULL_TREE
408 && CONSTANT_CLASS_P (res))
409 return res;
412 /* Canonicalize operand order both for matching and fallback stmt
413 generation. */
414 if ((commutative_tree_code (code)
415 || TREE_CODE_CLASS (code) == tcc_comparison)
416 && tree_swap_operands_p (op0, op1, false))
418 tree tem = op0;
419 op0 = op1;
420 op1 = tem;
421 if (TREE_CODE_CLASS (code) == tcc_comparison)
422 code = swap_tree_comparison (code);
425 code_helper rcode;
426 tree ops[3] = {};
427 if (!gimple_simplify (&rcode, ops, seq, valueize,
428 code, type, op0, op1))
429 return NULL_TREE;
430 return maybe_push_res_to_seq (rcode, type, ops, seq);
433 /* Ternary ops. */
435 tree
436 gimple_simplify (enum tree_code code, tree type,
437 tree op0, tree op1, tree op2,
438 gimple_seq *seq, tree (*valueize)(tree))
440 if (constant_for_folding (op0) && constant_for_folding (op1)
441 && constant_for_folding (op2))
443 tree res = fold_ternary/*_to_constant */ (code, type, op0, op1, op2);
444 if (res != NULL_TREE
445 && CONSTANT_CLASS_P (res))
446 return res;
449 /* Canonicalize operand order both for matching and fallback stmt
450 generation. */
451 if (commutative_ternary_tree_code (code)
452 && tree_swap_operands_p (op0, op1, false))
454 tree tem = op0;
455 op0 = op1;
456 op1 = tem;
459 code_helper rcode;
460 tree ops[3] = {};
461 if (!gimple_simplify (&rcode, ops, seq, valueize,
462 code, type, op0, op1, op2))
463 return NULL_TREE;
464 return maybe_push_res_to_seq (rcode, type, ops, seq);
467 /* Builtin function with one argument. */
469 tree
470 gimple_simplify (enum built_in_function fn, tree type,
471 tree arg0,
472 gimple_seq *seq, tree (*valueize)(tree))
474 if (constant_for_folding (arg0))
476 tree decl = builtin_decl_implicit (fn);
477 if (decl)
479 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, &arg0, 1, false);
480 if (res)
482 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
483 STRIP_NOPS (res);
484 res = fold_convert (type, res);
485 if (CONSTANT_CLASS_P (res))
486 return res;
491 code_helper rcode;
492 tree ops[3] = {};
493 if (!gimple_simplify (&rcode, ops, seq, valueize,
494 fn, type, arg0))
495 return NULL_TREE;
496 return maybe_push_res_to_seq (rcode, type, ops, seq);
499 /* Builtin function with two arguments. */
501 tree
502 gimple_simplify (enum built_in_function fn, tree type,
503 tree arg0, tree arg1,
504 gimple_seq *seq, tree (*valueize)(tree))
506 if (constant_for_folding (arg0)
507 && constant_for_folding (arg1))
509 tree decl = builtin_decl_implicit (fn);
510 if (decl)
512 tree args[2];
513 args[0] = arg0;
514 args[1] = arg1;
515 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 2, false);
516 if (res)
518 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
519 STRIP_NOPS (res);
520 res = fold_convert (type, res);
521 if (CONSTANT_CLASS_P (res))
522 return res;
527 code_helper rcode;
528 tree ops[3] = {};
529 if (!gimple_simplify (&rcode, ops, seq, valueize,
530 fn, type, arg0, arg1))
531 return NULL_TREE;
532 return maybe_push_res_to_seq (rcode, type, ops, seq);
535 /* Builtin function with three arguments. */
537 tree
538 gimple_simplify (enum built_in_function fn, tree type,
539 tree arg0, tree arg1, tree arg2,
540 gimple_seq *seq, tree (*valueize)(tree))
542 if (constant_for_folding (arg0)
543 && constant_for_folding (arg1)
544 && constant_for_folding (arg2))
546 tree decl = builtin_decl_implicit (fn);
547 if (decl)
549 tree args[3];
550 args[0] = arg0;
551 args[1] = arg1;
552 args[2] = arg2;
553 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 3, false);
554 if (res)
556 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
557 STRIP_NOPS (res);
558 res = fold_convert (type, res);
559 if (CONSTANT_CLASS_P (res))
560 return res;
565 code_helper rcode;
566 tree ops[3] = {};
567 if (!gimple_simplify (&rcode, ops, seq, valueize,
568 fn, type, arg0, arg1, arg2))
569 return NULL_TREE;
570 return maybe_push_res_to_seq (rcode, type, ops, seq);
574 /* The main STMT based simplification entry. It is used by the fold_stmt
575 and the fold_stmt_to_constant APIs. */
577 bool
578 gimple_simplify (gimple stmt,
579 code_helper *rcode, tree *ops,
580 gimple_seq *seq, tree (*valueize)(tree))
582 switch (gimple_code (stmt))
584 case GIMPLE_ASSIGN:
586 enum tree_code code = gimple_assign_rhs_code (stmt);
587 tree type = TREE_TYPE (gimple_assign_lhs (stmt));
588 switch (gimple_assign_rhs_class (stmt))
590 case GIMPLE_SINGLE_RHS:
591 if (code == REALPART_EXPR
592 || code == IMAGPART_EXPR
593 || code == VIEW_CONVERT_EXPR)
595 tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
596 if (valueize && TREE_CODE (op0) == SSA_NAME)
598 tree tem = valueize (op0);
599 if (tem)
600 op0 = tem;
602 *rcode = code;
603 ops[0] = op0;
604 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
606 else if (code == BIT_FIELD_REF)
608 tree rhs1 = gimple_assign_rhs1 (stmt);
609 tree op0 = TREE_OPERAND (rhs1, 0);
610 if (valueize && TREE_CODE (op0) == SSA_NAME)
612 tree tem = valueize (op0);
613 if (tem)
614 op0 = tem;
616 *rcode = code;
617 ops[0] = op0;
618 ops[1] = TREE_OPERAND (rhs1, 1);
619 ops[2] = TREE_OPERAND (rhs1, 2);
620 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
622 else if (code == SSA_NAME
623 && valueize)
625 tree op0 = gimple_assign_rhs1 (stmt);
626 tree valueized = valueize (op0);
627 if (!valueized || op0 == valueized)
628 return false;
629 ops[0] = valueized;
630 *rcode = TREE_CODE (op0);
631 return true;
633 break;
634 case GIMPLE_UNARY_RHS:
636 tree rhs1 = gimple_assign_rhs1 (stmt);
637 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
639 tree tem = valueize (rhs1);
640 if (tem)
641 rhs1 = tem;
643 *rcode = code;
644 ops[0] = rhs1;
645 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
647 case GIMPLE_BINARY_RHS:
649 tree rhs1 = gimple_assign_rhs1 (stmt);
650 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
652 tree tem = valueize (rhs1);
653 if (tem)
654 rhs1 = tem;
656 tree rhs2 = gimple_assign_rhs2 (stmt);
657 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
659 tree tem = valueize (rhs2);
660 if (tem)
661 rhs2 = tem;
663 *rcode = code;
664 ops[0] = rhs1;
665 ops[1] = rhs2;
666 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
668 case GIMPLE_TERNARY_RHS:
670 tree rhs1 = gimple_assign_rhs1 (stmt);
671 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
673 tree tem = valueize (rhs1);
674 if (tem)
675 rhs1 = tem;
677 tree rhs2 = gimple_assign_rhs2 (stmt);
678 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
680 tree tem = valueize (rhs2);
681 if (tem)
682 rhs2 = tem;
684 tree rhs3 = gimple_assign_rhs3 (stmt);
685 if (valueize && TREE_CODE (rhs3) == SSA_NAME)
687 tree tem = valueize (rhs3);
688 if (tem)
689 rhs3 = tem;
691 *rcode = code;
692 ops[0] = rhs1;
693 ops[1] = rhs2;
694 ops[2] = rhs3;
695 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
697 default:
698 gcc_unreachable ();
700 break;
703 case GIMPLE_CALL:
704 /* ??? This way we can't simplify calls with side-effects. */
705 if (gimple_call_lhs (stmt) != NULL_TREE)
707 tree fn = gimple_call_fn (stmt);
708 /* ??? Internal function support missing. */
709 if (!fn)
710 return false;
711 if (valueize && TREE_CODE (fn) == SSA_NAME)
713 tree tem = valueize (fn);
714 if (tem)
715 fn = tem;
717 if (!fn
718 || TREE_CODE (fn) != ADDR_EXPR
719 || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL
720 || DECL_BUILT_IN_CLASS (TREE_OPERAND (fn, 0)) != BUILT_IN_NORMAL
721 || !builtin_decl_implicit (DECL_FUNCTION_CODE (TREE_OPERAND (fn, 0)))
722 || !gimple_builtin_call_types_compatible_p (stmt,
723 TREE_OPERAND (fn, 0)))
724 return false;
726 tree decl = TREE_OPERAND (fn, 0);
727 tree type = TREE_TYPE (gimple_call_lhs (stmt));
728 switch (gimple_call_num_args (stmt))
730 case 1:
732 tree arg1 = gimple_call_arg (stmt, 0);
733 if (valueize && TREE_CODE (arg1) == SSA_NAME)
735 tree tem = valueize (arg1);
736 if (tem)
737 arg1 = tem;
739 *rcode = DECL_FUNCTION_CODE (decl);
740 ops[0] = arg1;
741 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
743 case 2:
745 tree arg1 = gimple_call_arg (stmt, 0);
746 if (valueize && TREE_CODE (arg1) == SSA_NAME)
748 tree tem = valueize (arg1);
749 if (tem)
750 arg1 = tem;
752 tree arg2 = gimple_call_arg (stmt, 1);
753 if (valueize && TREE_CODE (arg2) == SSA_NAME)
755 tree tem = valueize (arg2);
756 if (tem)
757 arg2 = tem;
759 *rcode = DECL_FUNCTION_CODE (decl);
760 ops[0] = arg1;
761 ops[1] = arg2;
762 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
764 case 3:
766 tree arg1 = gimple_call_arg (stmt, 0);
767 if (valueize && TREE_CODE (arg1) == SSA_NAME)
769 tree tem = valueize (arg1);
770 if (tem)
771 arg1 = tem;
773 tree arg2 = gimple_call_arg (stmt, 1);
774 if (valueize && TREE_CODE (arg2) == SSA_NAME)
776 tree tem = valueize (arg2);
777 if (tem)
778 arg2 = tem;
780 tree arg3 = gimple_call_arg (stmt, 2);
781 if (valueize && TREE_CODE (arg3) == SSA_NAME)
783 tree tem = valueize (arg3);
784 if (tem)
785 arg3 = tem;
787 *rcode = DECL_FUNCTION_CODE (decl);
788 ops[0] = arg1;
789 ops[1] = arg2;
790 ops[2] = arg3;
791 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
793 default:
794 return false;
797 break;
799 case GIMPLE_COND:
801 tree lhs = gimple_cond_lhs (stmt);
802 if (valueize && TREE_CODE (lhs) == SSA_NAME)
804 tree tem = valueize (lhs);
805 if (tem)
806 lhs = tem;
808 tree rhs = gimple_cond_rhs (stmt);
809 if (valueize && TREE_CODE (rhs) == SSA_NAME)
811 tree tem = valueize (rhs);
812 if (tem)
813 rhs = tem;
815 *rcode = gimple_cond_code (stmt);
816 ops[0] = lhs;
817 ops[1] = rhs;
818 return gimple_resimplify2 (seq, rcode, boolean_type_node, ops, valueize);
821 default:
822 break;
825 return false;
829 /* Helper for the autogenerated code, valueize OP. */
831 inline tree
832 do_valueize (tree (*valueize)(tree), tree op)
834 if (valueize && TREE_CODE (op) == SSA_NAME)
835 return valueize (op);
836 return op;