/cp
[official-gcc.git] / gcc / gimple-match-head.c
blobd7ada77bfc1942b29c5b0bed11c2d43d10d714c1
1 /* Preamble and helpers for the autogenerated gimple-match.c file.
2 Copyright (C) 2014-2015 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 "tm.h"
24 #include "hash-set.h"
25 #include "machmode.h"
26 #include "vec.h"
27 #include "double-int.h"
28 #include "input.h"
29 #include "alias.h"
30 #include "symtab.h"
31 #include "options.h"
32 #include "wide-int.h"
33 #include "inchash.h"
34 #include "tree.h"
35 #include "fold-const.h"
36 #include "stringpool.h"
37 #include "stor-layout.h"
38 #include "flags.h"
39 #include "tm.h"
40 #include "hard-reg-set.h"
41 #include "function.h"
42 #include "predict.h"
43 #include "input.h"
44 #include "basic-block.h"
45 #include "tree-ssa-alias.h"
46 #include "internal-fn.h"
47 #include "gimple-expr.h"
48 #include "is-a.h"
49 #include "gimple.h"
50 #include "gimple-ssa.h"
51 #include "tree-ssanames.h"
52 #include "gimple-fold.h"
53 #include "gimple-iterator.h"
54 #include "expr.h"
55 #include "tree-dfa.h"
56 #include "builtins.h"
57 #include "tree-phinodes.h"
58 #include "ssa-iterators.h"
59 #include "dumpfile.h"
60 #include "gimple-match.h"
63 /* Forward declarations of the private auto-generated matchers.
64 They expect valueized operands in canonical order and do not
65 perform simplification of all-constant operands. */
66 static bool gimple_simplify (code_helper *, tree *,
67 gimple_seq *, tree (*)(tree),
68 code_helper, tree, tree);
69 static bool gimple_simplify (code_helper *, tree *,
70 gimple_seq *, tree (*)(tree),
71 code_helper, tree, tree, tree);
72 static bool gimple_simplify (code_helper *, tree *,
73 gimple_seq *, tree (*)(tree),
74 code_helper, tree, tree, tree, tree);
77 /* Return whether T is a constant that we'll dispatch to fold to
78 evaluate fully constant expressions. */
80 static inline bool
81 constant_for_folding (tree t)
83 return (CONSTANT_CLASS_P (t)
84 /* The following is only interesting to string builtins. */
85 || (TREE_CODE (t) == ADDR_EXPR
86 && TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST));
90 /* Helper that matches and simplifies the toplevel result from
91 a gimple_simplify run (where we don't want to build
92 a stmt in case it's used in in-place folding). Replaces
93 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
94 result and returns whether any change was made. */
96 static bool
97 gimple_resimplify1 (gimple_seq *seq,
98 code_helper *res_code, tree type, tree *res_ops,
99 tree (*valueize)(tree))
101 if (constant_for_folding (res_ops[0]))
103 tree tem = NULL_TREE;
104 if (res_code->is_tree_code ())
105 tem = const_unop (*res_code, type, res_ops[0]);
106 else
108 tree decl = builtin_decl_implicit (*res_code);
109 if (decl)
111 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 1, false);
112 if (tem)
114 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
115 STRIP_NOPS (tem);
116 tem = fold_convert (type, tem);
120 if (tem != NULL_TREE
121 && CONSTANT_CLASS_P (tem))
123 res_ops[0] = tem;
124 res_ops[1] = NULL_TREE;
125 res_ops[2] = NULL_TREE;
126 *res_code = TREE_CODE (res_ops[0]);
127 return true;
131 code_helper res_code2;
132 tree res_ops2[3] = {};
133 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
134 *res_code, type, res_ops[0]))
136 *res_code = res_code2;
137 res_ops[0] = res_ops2[0];
138 res_ops[1] = res_ops2[1];
139 res_ops[2] = res_ops2[2];
140 return true;
143 return false;
146 /* Helper that matches and simplifies the toplevel result from
147 a gimple_simplify run (where we don't want to build
148 a stmt in case it's used in in-place folding). Replaces
149 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
150 result and returns whether any change was made. */
152 static bool
153 gimple_resimplify2 (gimple_seq *seq,
154 code_helper *res_code, tree type, tree *res_ops,
155 tree (*valueize)(tree))
157 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1]))
159 tree tem = NULL_TREE;
160 if (res_code->is_tree_code ())
161 tem = const_binop (*res_code, type, res_ops[0], res_ops[1]);
162 else
164 tree decl = builtin_decl_implicit (*res_code);
165 if (decl)
167 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 2, false);
168 if (tem)
170 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
171 STRIP_NOPS (tem);
172 tem = fold_convert (type, tem);
176 if (tem != NULL_TREE
177 && CONSTANT_CLASS_P (tem))
179 res_ops[0] = tem;
180 res_ops[1] = NULL_TREE;
181 res_ops[2] = NULL_TREE;
182 *res_code = TREE_CODE (res_ops[0]);
183 return true;
187 /* Canonicalize operand order. */
188 bool canonicalized = false;
189 if (res_code->is_tree_code ()
190 && (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison
191 || commutative_tree_code (*res_code))
192 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
194 tree tem = res_ops[0];
195 res_ops[0] = res_ops[1];
196 res_ops[1] = tem;
197 if (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison)
198 *res_code = swap_tree_comparison (*res_code);
199 canonicalized = true;
202 code_helper res_code2;
203 tree res_ops2[3] = {};
204 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
205 *res_code, type, res_ops[0], res_ops[1]))
207 *res_code = res_code2;
208 res_ops[0] = res_ops2[0];
209 res_ops[1] = res_ops2[1];
210 res_ops[2] = res_ops2[2];
211 return true;
214 return canonicalized;
217 /* Helper that matches and simplifies the toplevel result from
218 a gimple_simplify run (where we don't want to build
219 a stmt in case it's used in in-place folding). Replaces
220 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
221 result and returns whether any change was made. */
223 static bool
224 gimple_resimplify3 (gimple_seq *seq,
225 code_helper *res_code, tree type, tree *res_ops,
226 tree (*valueize)(tree))
228 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1])
229 && constant_for_folding (res_ops[2]))
231 tree tem = NULL_TREE;
232 if (res_code->is_tree_code ())
233 tem = fold_ternary/*_to_constant*/ (*res_code, type, res_ops[0],
234 res_ops[1], res_ops[2]);
235 else
237 tree decl = builtin_decl_implicit (*res_code);
238 if (decl)
240 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 3, false);
241 if (tem)
243 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
244 STRIP_NOPS (tem);
245 tem = fold_convert (type, tem);
249 if (tem != NULL_TREE
250 && CONSTANT_CLASS_P (tem))
252 res_ops[0] = tem;
253 res_ops[1] = NULL_TREE;
254 res_ops[2] = NULL_TREE;
255 *res_code = TREE_CODE (res_ops[0]);
256 return true;
260 /* Canonicalize operand order. */
261 bool canonicalized = false;
262 if (res_code->is_tree_code ()
263 && commutative_ternary_tree_code (*res_code)
264 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
266 tree tem = res_ops[0];
267 res_ops[0] = res_ops[1];
268 res_ops[1] = tem;
269 canonicalized = true;
272 code_helper res_code2;
273 tree res_ops2[3] = {};
274 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
275 *res_code, type,
276 res_ops[0], res_ops[1], res_ops[2]))
278 *res_code = res_code2;
279 res_ops[0] = res_ops2[0];
280 res_ops[1] = res_ops2[1];
281 res_ops[2] = res_ops2[2];
282 return true;
285 return canonicalized;
289 /* If in GIMPLE expressions with CODE go as single-rhs build
290 a GENERIC tree for that expression into *OP0. */
292 void
293 maybe_build_generic_op (enum tree_code code, tree type,
294 tree *op0, tree op1, tree op2)
296 switch (code)
298 case REALPART_EXPR:
299 case IMAGPART_EXPR:
300 case VIEW_CONVERT_EXPR:
301 *op0 = build1 (code, type, *op0);
302 break;
303 case BIT_FIELD_REF:
304 *op0 = build3 (code, type, *op0, op1, op2);
305 break;
306 default:;
310 /* Push the exploded expression described by RCODE, TYPE and OPS
311 as a statement to SEQ if necessary and return a gimple value
312 denoting the value of the expression. If RES is not NULL
313 then the result will be always RES and even gimple values are
314 pushed to SEQ. */
316 tree
317 maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
318 gimple_seq *seq, tree res)
320 if (rcode.is_tree_code ())
322 if (!res
323 && (TREE_CODE_LENGTH ((tree_code) rcode) == 0
324 || ((tree_code) rcode) == ADDR_EXPR)
325 && is_gimple_val (ops[0]))
326 return ops[0];
327 if (!seq)
328 return NULL_TREE;
329 /* Play safe and do not allow abnormals to be mentioned in
330 newly created statements. */
331 if ((TREE_CODE (ops[0]) == SSA_NAME
332 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
333 || (ops[1]
334 && TREE_CODE (ops[1]) == SSA_NAME
335 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
336 || (ops[2]
337 && TREE_CODE (ops[2]) == SSA_NAME
338 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
339 return NULL_TREE;
340 if (!res)
341 res = make_ssa_name (type);
342 maybe_build_generic_op (rcode, type, &ops[0], ops[1], ops[2]);
343 gimple new_stmt = gimple_build_assign (res, rcode,
344 ops[0], ops[1], ops[2]);
345 gimple_seq_add_stmt_without_update (seq, new_stmt);
346 return res;
348 else
350 if (!seq)
351 return NULL_TREE;
352 tree decl = builtin_decl_implicit (rcode);
353 if (!decl)
354 return NULL_TREE;
355 unsigned nargs = type_num_arguments (TREE_TYPE (decl));
356 gcc_assert (nargs <= 3);
357 /* Play safe and do not allow abnormals to be mentioned in
358 newly created statements. */
359 if ((TREE_CODE (ops[0]) == SSA_NAME
360 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
361 || (nargs >= 2
362 && TREE_CODE (ops[1]) == SSA_NAME
363 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
364 || (nargs == 3
365 && TREE_CODE (ops[2]) == SSA_NAME
366 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
367 return NULL_TREE;
368 if (!res)
369 res = make_ssa_name (type);
370 gimple new_stmt = gimple_build_call (decl, nargs, ops[0], ops[1], ops[2]);
371 gimple_call_set_lhs (new_stmt, res);
372 gimple_seq_add_stmt_without_update (seq, new_stmt);
373 return res;
378 /* Public API overloads follow for operation being tree_code or
379 built_in_function and for one to three operands or arguments.
380 They return NULL_TREE if nothing could be simplified or
381 the resulting simplified value with parts pushed to SEQ.
382 If SEQ is NULL then if the simplification needs to create
383 new stmts it will fail. If VALUEIZE is non-NULL then all
384 SSA names will be valueized using that hook prior to
385 applying simplifications. */
387 /* Unary ops. */
389 tree
390 gimple_simplify (enum tree_code code, tree type,
391 tree op0,
392 gimple_seq *seq, tree (*valueize)(tree))
394 if (constant_for_folding (op0))
396 tree res = const_unop (code, type, op0);
397 if (res != NULL_TREE
398 && CONSTANT_CLASS_P (res))
399 return res;
402 code_helper rcode;
403 tree ops[3] = {};
404 if (!gimple_simplify (&rcode, ops, seq, valueize,
405 code, type, op0))
406 return NULL_TREE;
407 return maybe_push_res_to_seq (rcode, type, ops, seq);
410 /* Binary ops. */
412 tree
413 gimple_simplify (enum tree_code code, tree type,
414 tree op0, tree op1,
415 gimple_seq *seq, tree (*valueize)(tree))
417 if (constant_for_folding (op0) && constant_for_folding (op1))
419 tree res = const_binop (code, type, op0, op1);
420 if (res != NULL_TREE
421 && CONSTANT_CLASS_P (res))
422 return res;
425 /* Canonicalize operand order both for matching and fallback stmt
426 generation. */
427 if ((commutative_tree_code (code)
428 || TREE_CODE_CLASS (code) == tcc_comparison)
429 && tree_swap_operands_p (op0, op1, false))
431 tree tem = op0;
432 op0 = op1;
433 op1 = tem;
434 if (TREE_CODE_CLASS (code) == tcc_comparison)
435 code = swap_tree_comparison (code);
438 code_helper rcode;
439 tree ops[3] = {};
440 if (!gimple_simplify (&rcode, ops, seq, valueize,
441 code, type, op0, op1))
442 return NULL_TREE;
443 return maybe_push_res_to_seq (rcode, type, ops, seq);
446 /* Ternary ops. */
448 tree
449 gimple_simplify (enum tree_code code, tree type,
450 tree op0, tree op1, tree op2,
451 gimple_seq *seq, tree (*valueize)(tree))
453 if (constant_for_folding (op0) && constant_for_folding (op1)
454 && constant_for_folding (op2))
456 tree res = fold_ternary/*_to_constant */ (code, type, op0, op1, op2);
457 if (res != NULL_TREE
458 && CONSTANT_CLASS_P (res))
459 return res;
462 /* Canonicalize operand order both for matching and fallback stmt
463 generation. */
464 if (commutative_ternary_tree_code (code)
465 && tree_swap_operands_p (op0, op1, false))
467 tree tem = op0;
468 op0 = op1;
469 op1 = tem;
472 code_helper rcode;
473 tree ops[3] = {};
474 if (!gimple_simplify (&rcode, ops, seq, valueize,
475 code, type, op0, op1, op2))
476 return NULL_TREE;
477 return maybe_push_res_to_seq (rcode, type, ops, seq);
480 /* Builtin function with one argument. */
482 tree
483 gimple_simplify (enum built_in_function fn, tree type,
484 tree arg0,
485 gimple_seq *seq, tree (*valueize)(tree))
487 if (constant_for_folding (arg0))
489 tree decl = builtin_decl_implicit (fn);
490 if (decl)
492 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, &arg0, 1, false);
493 if (res)
495 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
496 STRIP_NOPS (res);
497 res = fold_convert (type, res);
498 if (CONSTANT_CLASS_P (res))
499 return res;
504 code_helper rcode;
505 tree ops[3] = {};
506 if (!gimple_simplify (&rcode, ops, seq, valueize,
507 fn, type, arg0))
508 return NULL_TREE;
509 return maybe_push_res_to_seq (rcode, type, ops, seq);
512 /* Builtin function with two arguments. */
514 tree
515 gimple_simplify (enum built_in_function fn, tree type,
516 tree arg0, tree arg1,
517 gimple_seq *seq, tree (*valueize)(tree))
519 if (constant_for_folding (arg0)
520 && constant_for_folding (arg1))
522 tree decl = builtin_decl_implicit (fn);
523 if (decl)
525 tree args[2];
526 args[0] = arg0;
527 args[1] = arg1;
528 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 2, false);
529 if (res)
531 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
532 STRIP_NOPS (res);
533 res = fold_convert (type, res);
534 if (CONSTANT_CLASS_P (res))
535 return res;
540 code_helper rcode;
541 tree ops[3] = {};
542 if (!gimple_simplify (&rcode, ops, seq, valueize,
543 fn, type, arg0, arg1))
544 return NULL_TREE;
545 return maybe_push_res_to_seq (rcode, type, ops, seq);
548 /* Builtin function with three arguments. */
550 tree
551 gimple_simplify (enum built_in_function fn, tree type,
552 tree arg0, tree arg1, tree arg2,
553 gimple_seq *seq, tree (*valueize)(tree))
555 if (constant_for_folding (arg0)
556 && constant_for_folding (arg1)
557 && constant_for_folding (arg2))
559 tree decl = builtin_decl_implicit (fn);
560 if (decl)
562 tree args[3];
563 args[0] = arg0;
564 args[1] = arg1;
565 args[2] = arg2;
566 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 3, false);
567 if (res)
569 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
570 STRIP_NOPS (res);
571 res = fold_convert (type, res);
572 if (CONSTANT_CLASS_P (res))
573 return res;
578 code_helper rcode;
579 tree ops[3] = {};
580 if (!gimple_simplify (&rcode, ops, seq, valueize,
581 fn, type, arg0, arg1, arg2))
582 return NULL_TREE;
583 return maybe_push_res_to_seq (rcode, type, ops, seq);
587 /* The main STMT based simplification entry. It is used by the fold_stmt
588 and the fold_stmt_to_constant APIs. */
590 bool
591 gimple_simplify (gimple stmt,
592 code_helper *rcode, tree *ops,
593 gimple_seq *seq, tree (*valueize)(tree))
595 switch (gimple_code (stmt))
597 case GIMPLE_ASSIGN:
599 enum tree_code code = gimple_assign_rhs_code (stmt);
600 tree type = TREE_TYPE (gimple_assign_lhs (stmt));
601 switch (gimple_assign_rhs_class (stmt))
603 case GIMPLE_SINGLE_RHS:
604 if (code == REALPART_EXPR
605 || code == IMAGPART_EXPR
606 || code == VIEW_CONVERT_EXPR)
608 tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
609 if (valueize && TREE_CODE (op0) == SSA_NAME)
611 tree tem = valueize (op0);
612 if (tem)
613 op0 = tem;
615 *rcode = code;
616 ops[0] = op0;
617 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
619 else if (code == BIT_FIELD_REF)
621 tree rhs1 = gimple_assign_rhs1 (stmt);
622 tree op0 = TREE_OPERAND (rhs1, 0);
623 if (valueize && TREE_CODE (op0) == SSA_NAME)
625 tree tem = valueize (op0);
626 if (tem)
627 op0 = tem;
629 *rcode = code;
630 ops[0] = op0;
631 ops[1] = TREE_OPERAND (rhs1, 1);
632 ops[2] = TREE_OPERAND (rhs1, 2);
633 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
635 else if (code == SSA_NAME
636 && valueize)
638 tree op0 = gimple_assign_rhs1 (stmt);
639 tree valueized = valueize (op0);
640 if (!valueized || op0 == valueized)
641 return false;
642 ops[0] = valueized;
643 *rcode = TREE_CODE (op0);
644 return true;
646 break;
647 case GIMPLE_UNARY_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 *rcode = code;
657 ops[0] = rhs1;
658 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
660 case GIMPLE_BINARY_RHS:
662 tree rhs1 = gimple_assign_rhs1 (stmt);
663 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
665 tree tem = valueize (rhs1);
666 if (tem)
667 rhs1 = tem;
669 tree rhs2 = gimple_assign_rhs2 (stmt);
670 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
672 tree tem = valueize (rhs2);
673 if (tem)
674 rhs2 = tem;
676 *rcode = code;
677 ops[0] = rhs1;
678 ops[1] = rhs2;
679 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
681 case GIMPLE_TERNARY_RHS:
683 tree rhs1 = gimple_assign_rhs1 (stmt);
684 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
686 tree tem = valueize (rhs1);
687 if (tem)
688 rhs1 = tem;
690 tree rhs2 = gimple_assign_rhs2 (stmt);
691 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
693 tree tem = valueize (rhs2);
694 if (tem)
695 rhs2 = tem;
697 tree rhs3 = gimple_assign_rhs3 (stmt);
698 if (valueize && TREE_CODE (rhs3) == SSA_NAME)
700 tree tem = valueize (rhs3);
701 if (tem)
702 rhs3 = tem;
704 *rcode = code;
705 ops[0] = rhs1;
706 ops[1] = rhs2;
707 ops[2] = rhs3;
708 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
710 default:
711 gcc_unreachable ();
713 break;
716 case GIMPLE_CALL:
717 /* ??? This way we can't simplify calls with side-effects. */
718 if (gimple_call_lhs (stmt) != NULL_TREE)
720 tree fn = gimple_call_fn (stmt);
721 /* ??? Internal function support missing. */
722 if (!fn)
723 return false;
724 if (valueize && TREE_CODE (fn) == SSA_NAME)
726 tree tem = valueize (fn);
727 if (tem)
728 fn = tem;
730 if (!fn
731 || TREE_CODE (fn) != ADDR_EXPR
732 || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL
733 || DECL_BUILT_IN_CLASS (TREE_OPERAND (fn, 0)) != BUILT_IN_NORMAL
734 || !builtin_decl_implicit (DECL_FUNCTION_CODE (TREE_OPERAND (fn, 0)))
735 || !gimple_builtin_call_types_compatible_p (stmt,
736 TREE_OPERAND (fn, 0)))
737 return false;
739 tree decl = TREE_OPERAND (fn, 0);
740 tree type = TREE_TYPE (gimple_call_lhs (stmt));
741 switch (gimple_call_num_args (stmt))
743 case 1:
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 *rcode = DECL_FUNCTION_CODE (decl);
753 ops[0] = arg1;
754 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
756 case 2:
758 tree arg1 = gimple_call_arg (stmt, 0);
759 if (valueize && TREE_CODE (arg1) == SSA_NAME)
761 tree tem = valueize (arg1);
762 if (tem)
763 arg1 = tem;
765 tree arg2 = gimple_call_arg (stmt, 1);
766 if (valueize && TREE_CODE (arg2) == SSA_NAME)
768 tree tem = valueize (arg2);
769 if (tem)
770 arg2 = tem;
772 *rcode = DECL_FUNCTION_CODE (decl);
773 ops[0] = arg1;
774 ops[1] = arg2;
775 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
777 case 3:
779 tree arg1 = gimple_call_arg (stmt, 0);
780 if (valueize && TREE_CODE (arg1) == SSA_NAME)
782 tree tem = valueize (arg1);
783 if (tem)
784 arg1 = tem;
786 tree arg2 = gimple_call_arg (stmt, 1);
787 if (valueize && TREE_CODE (arg2) == SSA_NAME)
789 tree tem = valueize (arg2);
790 if (tem)
791 arg2 = tem;
793 tree arg3 = gimple_call_arg (stmt, 2);
794 if (valueize && TREE_CODE (arg3) == SSA_NAME)
796 tree tem = valueize (arg3);
797 if (tem)
798 arg3 = tem;
800 *rcode = DECL_FUNCTION_CODE (decl);
801 ops[0] = arg1;
802 ops[1] = arg2;
803 ops[2] = arg3;
804 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
806 default:
807 return false;
810 break;
812 case GIMPLE_COND:
814 tree lhs = gimple_cond_lhs (stmt);
815 if (valueize && TREE_CODE (lhs) == SSA_NAME)
817 tree tem = valueize (lhs);
818 if (tem)
819 lhs = tem;
821 tree rhs = gimple_cond_rhs (stmt);
822 if (valueize && TREE_CODE (rhs) == SSA_NAME)
824 tree tem = valueize (rhs);
825 if (tem)
826 rhs = tem;
828 *rcode = gimple_cond_code (stmt);
829 ops[0] = lhs;
830 ops[1] = rhs;
831 return gimple_resimplify2 (seq, rcode, boolean_type_node, ops, valueize);
834 default:
835 break;
838 return false;
842 /* Helper for the autogenerated code, valueize OP. */
844 inline tree
845 do_valueize (tree (*valueize)(tree), tree op)
847 if (valueize && TREE_CODE (op) == SSA_NAME)
848 return valueize (op);
849 return op;