Daily bump.
[official-gcc.git] / gcc / gimple-match-head.c
blob9c6da59d44b0a0dec7a52f1eecff78ff15819a5f
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 = fold_unary_to_constant (*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 = fold_binary_to_constant (*res_code, type,
154 res_ops[0], res_ops[1]);
155 else
157 tree decl = builtin_decl_implicit (*res_code);
158 if (decl)
160 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 2, false);
161 if (tem)
163 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
164 STRIP_NOPS (tem);
165 tem = fold_convert (type, tem);
169 if (tem != NULL_TREE
170 && CONSTANT_CLASS_P (tem))
172 res_ops[0] = tem;
173 res_ops[1] = NULL_TREE;
174 res_ops[2] = NULL_TREE;
175 *res_code = TREE_CODE (res_ops[0]);
176 return true;
180 /* Canonicalize operand order. */
181 bool canonicalized = false;
182 if (res_code->is_tree_code ()
183 && (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison
184 || commutative_tree_code (*res_code))
185 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
187 tree tem = res_ops[0];
188 res_ops[0] = res_ops[1];
189 res_ops[1] = tem;
190 if (TREE_CODE_CLASS ((enum tree_code) *res_code) == tcc_comparison)
191 *res_code = swap_tree_comparison (*res_code);
192 canonicalized = true;
195 code_helper res_code2;
196 tree res_ops2[3] = {};
197 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
198 *res_code, type, res_ops[0], res_ops[1]))
200 *res_code = res_code2;
201 res_ops[0] = res_ops2[0];
202 res_ops[1] = res_ops2[1];
203 res_ops[2] = res_ops2[2];
204 return true;
207 return canonicalized;
210 /* Helper that matches and simplifies the toplevel result from
211 a gimple_simplify run (where we don't want to build
212 a stmt in case it's used in in-place folding). Replaces
213 *RES_CODE and *RES_OPS with a simplified and/or canonicalized
214 result and returns whether any change was made. */
216 static bool
217 gimple_resimplify3 (gimple_seq *seq,
218 code_helper *res_code, tree type, tree *res_ops,
219 tree (*valueize)(tree))
221 if (constant_for_folding (res_ops[0]) && constant_for_folding (res_ops[1])
222 && constant_for_folding (res_ops[2]))
224 tree tem = NULL_TREE;
225 if (res_code->is_tree_code ())
226 tem = fold_ternary/*_to_constant*/ (*res_code, type, res_ops[0],
227 res_ops[1], res_ops[2]);
228 else
230 tree decl = builtin_decl_implicit (*res_code);
231 if (decl)
233 tem = fold_builtin_n (UNKNOWN_LOCATION, decl, res_ops, 3, false);
234 if (tem)
236 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
237 STRIP_NOPS (tem);
238 tem = fold_convert (type, tem);
242 if (tem != NULL_TREE
243 && CONSTANT_CLASS_P (tem))
245 res_ops[0] = tem;
246 res_ops[1] = NULL_TREE;
247 res_ops[2] = NULL_TREE;
248 *res_code = TREE_CODE (res_ops[0]);
249 return true;
253 /* Canonicalize operand order. */
254 bool canonicalized = false;
255 if (res_code->is_tree_code ()
256 && commutative_ternary_tree_code (*res_code)
257 && tree_swap_operands_p (res_ops[0], res_ops[1], false))
259 tree tem = res_ops[0];
260 res_ops[0] = res_ops[1];
261 res_ops[1] = tem;
262 canonicalized = true;
265 code_helper res_code2;
266 tree res_ops2[3] = {};
267 if (gimple_simplify (&res_code2, res_ops2, seq, valueize,
268 *res_code, type,
269 res_ops[0], res_ops[1], res_ops[2]))
271 *res_code = res_code2;
272 res_ops[0] = res_ops2[0];
273 res_ops[1] = res_ops2[1];
274 res_ops[2] = res_ops2[2];
275 return true;
278 return canonicalized;
282 /* If in GIMPLE expressions with CODE go as single-rhs build
283 a GENERIC tree for that expression into *OP0. */
285 void
286 maybe_build_generic_op (enum tree_code code, tree type,
287 tree *op0, tree op1, tree op2)
289 switch (code)
291 case REALPART_EXPR:
292 case IMAGPART_EXPR:
293 case VIEW_CONVERT_EXPR:
294 *op0 = build1 (code, type, *op0);
295 break;
296 case BIT_FIELD_REF:
297 *op0 = build3 (code, type, *op0, op1, op2);
298 break;
299 default:;
303 /* Push the exploded expression described by RCODE, TYPE and OPS
304 as a statement to SEQ if necessary and return a gimple value
305 denoting the value of the expression. If RES is not NULL
306 then the result will be always RES and even gimple values are
307 pushed to SEQ. */
309 tree
310 maybe_push_res_to_seq (code_helper rcode, tree type, tree *ops,
311 gimple_seq *seq, tree res)
313 if (rcode.is_tree_code ())
315 if (!res
316 && (TREE_CODE_LENGTH ((tree_code) rcode) == 0
317 || ((tree_code) rcode) == ADDR_EXPR)
318 && is_gimple_val (ops[0]))
319 return ops[0];
320 if (!seq)
321 return NULL_TREE;
322 /* Play safe and do not allow abnormals to be mentioned in
323 newly created statements. */
324 if ((TREE_CODE (ops[0]) == SSA_NAME
325 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
326 || (ops[1]
327 && TREE_CODE (ops[1]) == SSA_NAME
328 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
329 || (ops[2]
330 && TREE_CODE (ops[2]) == SSA_NAME
331 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
332 return NULL_TREE;
333 if (!res)
334 res = make_ssa_name (type, NULL);
335 maybe_build_generic_op (rcode, type, &ops[0], ops[1], ops[2]);
336 gimple new_stmt = gimple_build_assign_with_ops (rcode, res,
337 ops[0], ops[1], ops[2]);
338 gimple_seq_add_stmt_without_update (seq, new_stmt);
339 return res;
341 else
343 if (!seq)
344 return NULL_TREE;
345 tree decl = builtin_decl_implicit (rcode);
346 if (!decl)
347 return NULL_TREE;
348 unsigned nargs = type_num_arguments (TREE_TYPE (decl));
349 gcc_assert (nargs <= 3);
350 /* Play safe and do not allow abnormals to be mentioned in
351 newly created statements. */
352 if ((TREE_CODE (ops[0]) == SSA_NAME
353 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[0]))
354 || (nargs >= 2
355 && TREE_CODE (ops[1]) == SSA_NAME
356 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[1]))
357 || (nargs == 3
358 && TREE_CODE (ops[2]) == SSA_NAME
359 && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[2])))
360 return NULL_TREE;
361 if (!res)
362 res = make_ssa_name (type, NULL);
363 gimple new_stmt = gimple_build_call (decl, nargs, ops[0], ops[1], ops[2]);
364 gimple_call_set_lhs (new_stmt, res);
365 gimple_seq_add_stmt_without_update (seq, new_stmt);
366 return res;
371 /* Public API overloads follow for operation being tree_code or
372 built_in_function and for one to three operands or arguments.
373 They return NULL_TREE if nothing could be simplified or
374 the resulting simplified value with parts pushed to SEQ.
375 If SEQ is NULL then if the simplification needs to create
376 new stmts it will fail. If VALUEIZE is non-NULL then all
377 SSA names will be valueized using that hook prior to
378 applying simplifications. */
380 /* Unary ops. */
382 tree
383 gimple_simplify (enum tree_code code, tree type,
384 tree op0,
385 gimple_seq *seq, tree (*valueize)(tree))
387 if (constant_for_folding (op0))
389 tree res = fold_unary_to_constant (code, type, op0);
390 if (res != NULL_TREE
391 && CONSTANT_CLASS_P (res))
392 return res;
395 code_helper rcode;
396 tree ops[3] = {};
397 if (!gimple_simplify (&rcode, ops, seq, valueize,
398 code, type, op0))
399 return NULL_TREE;
400 return maybe_push_res_to_seq (rcode, type, ops, seq);
403 /* Binary ops. */
405 tree
406 gimple_simplify (enum tree_code code, tree type,
407 tree op0, tree op1,
408 gimple_seq *seq, tree (*valueize)(tree))
410 if (constant_for_folding (op0) && constant_for_folding (op1))
412 tree res = fold_binary_to_constant (code, type, op0, op1);
413 if (res != NULL_TREE
414 && CONSTANT_CLASS_P (res))
415 return res;
418 /* Canonicalize operand order both for matching and fallback stmt
419 generation. */
420 if ((commutative_tree_code (code)
421 || TREE_CODE_CLASS (code) == tcc_comparison)
422 && tree_swap_operands_p (op0, op1, false))
424 tree tem = op0;
425 op0 = op1;
426 op1 = tem;
427 if (TREE_CODE_CLASS (code) == tcc_comparison)
428 code = swap_tree_comparison (code);
431 code_helper rcode;
432 tree ops[3] = {};
433 if (!gimple_simplify (&rcode, ops, seq, valueize,
434 code, type, op0, op1))
435 return NULL_TREE;
436 return maybe_push_res_to_seq (rcode, type, ops, seq);
439 /* Ternary ops. */
441 tree
442 gimple_simplify (enum tree_code code, tree type,
443 tree op0, tree op1, tree op2,
444 gimple_seq *seq, tree (*valueize)(tree))
446 if (constant_for_folding (op0) && constant_for_folding (op1)
447 && constant_for_folding (op2))
449 tree res = fold_ternary/*_to_constant */ (code, type, op0, op1, op2);
450 if (res != NULL_TREE
451 && CONSTANT_CLASS_P (res))
452 return res;
455 /* Canonicalize operand order both for matching and fallback stmt
456 generation. */
457 if (commutative_ternary_tree_code (code)
458 && tree_swap_operands_p (op0, op1, false))
460 tree tem = op0;
461 op0 = op1;
462 op1 = tem;
465 code_helper rcode;
466 tree ops[3] = {};
467 if (!gimple_simplify (&rcode, ops, seq, valueize,
468 code, type, op0, op1, op2))
469 return NULL_TREE;
470 return maybe_push_res_to_seq (rcode, type, ops, seq);
473 /* Builtin function with one argument. */
475 tree
476 gimple_simplify (enum built_in_function fn, tree type,
477 tree arg0,
478 gimple_seq *seq, tree (*valueize)(tree))
480 if (constant_for_folding (arg0))
482 tree decl = builtin_decl_implicit (fn);
483 if (decl)
485 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, &arg0, 1, false);
486 if (res)
488 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
489 STRIP_NOPS (res);
490 res = fold_convert (type, res);
491 if (CONSTANT_CLASS_P (res))
492 return res;
497 code_helper rcode;
498 tree ops[3] = {};
499 if (!gimple_simplify (&rcode, ops, seq, valueize,
500 fn, type, arg0))
501 return NULL_TREE;
502 return maybe_push_res_to_seq (rcode, type, ops, seq);
505 /* Builtin function with two arguments. */
507 tree
508 gimple_simplify (enum built_in_function fn, tree type,
509 tree arg0, tree arg1,
510 gimple_seq *seq, tree (*valueize)(tree))
512 if (constant_for_folding (arg0)
513 && constant_for_folding (arg1))
515 tree decl = builtin_decl_implicit (fn);
516 if (decl)
518 tree args[2];
519 args[0] = arg0;
520 args[1] = arg1;
521 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 2, false);
522 if (res)
524 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
525 STRIP_NOPS (res);
526 res = fold_convert (type, res);
527 if (CONSTANT_CLASS_P (res))
528 return res;
533 code_helper rcode;
534 tree ops[3] = {};
535 if (!gimple_simplify (&rcode, ops, seq, valueize,
536 fn, type, arg0, arg1))
537 return NULL_TREE;
538 return maybe_push_res_to_seq (rcode, type, ops, seq);
541 /* Builtin function with three arguments. */
543 tree
544 gimple_simplify (enum built_in_function fn, tree type,
545 tree arg0, tree arg1, tree arg2,
546 gimple_seq *seq, tree (*valueize)(tree))
548 if (constant_for_folding (arg0)
549 && constant_for_folding (arg1)
550 && constant_for_folding (arg2))
552 tree decl = builtin_decl_implicit (fn);
553 if (decl)
555 tree args[3];
556 args[0] = arg0;
557 args[1] = arg1;
558 args[2] = arg2;
559 tree res = fold_builtin_n (UNKNOWN_LOCATION, decl, args, 3, false);
560 if (res)
562 /* fold_builtin_n wraps the result inside a NOP_EXPR. */
563 STRIP_NOPS (res);
564 res = fold_convert (type, res);
565 if (CONSTANT_CLASS_P (res))
566 return res;
571 code_helper rcode;
572 tree ops[3] = {};
573 if (!gimple_simplify (&rcode, ops, seq, valueize,
574 fn, type, arg0, arg1, arg2))
575 return NULL_TREE;
576 return maybe_push_res_to_seq (rcode, type, ops, seq);
580 /* The main STMT based simplification entry. It is used by the fold_stmt
581 and the fold_stmt_to_constant APIs. */
583 bool
584 gimple_simplify (gimple stmt,
585 code_helper *rcode, tree *ops,
586 gimple_seq *seq, tree (*valueize)(tree))
588 switch (gimple_code (stmt))
590 case GIMPLE_ASSIGN:
592 enum tree_code code = gimple_assign_rhs_code (stmt);
593 tree type = TREE_TYPE (gimple_assign_lhs (stmt));
594 switch (gimple_assign_rhs_class (stmt))
596 case GIMPLE_SINGLE_RHS:
597 if (code == REALPART_EXPR
598 || code == IMAGPART_EXPR
599 || code == VIEW_CONVERT_EXPR)
601 tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
602 if (valueize && TREE_CODE (op0) == SSA_NAME)
604 tree tem = valueize (op0);
605 if (tem)
606 op0 = tem;
608 *rcode = code;
609 ops[0] = op0;
610 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
612 else if (code == BIT_FIELD_REF)
614 tree rhs1 = gimple_assign_rhs1 (stmt);
615 tree op0 = TREE_OPERAND (rhs1, 0);
616 if (valueize && TREE_CODE (op0) == SSA_NAME)
618 tree tem = valueize (op0);
619 if (tem)
620 op0 = tem;
622 *rcode = code;
623 ops[0] = op0;
624 ops[1] = TREE_OPERAND (rhs1, 1);
625 ops[2] = TREE_OPERAND (rhs1, 2);
626 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
628 else if (code == SSA_NAME
629 && valueize)
631 tree op0 = gimple_assign_rhs1 (stmt);
632 tree valueized = valueize (op0);
633 if (!valueized || op0 == valueized)
634 return false;
635 ops[0] = valueized;
636 *rcode = TREE_CODE (op0);
637 return true;
639 break;
640 case GIMPLE_UNARY_RHS:
642 tree rhs1 = gimple_assign_rhs1 (stmt);
643 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
645 tree tem = valueize (rhs1);
646 if (tem)
647 rhs1 = tem;
649 *rcode = code;
650 ops[0] = rhs1;
651 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
653 case GIMPLE_BINARY_RHS:
655 tree rhs1 = gimple_assign_rhs1 (stmt);
656 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
658 tree tem = valueize (rhs1);
659 if (tem)
660 rhs1 = tem;
662 tree rhs2 = gimple_assign_rhs2 (stmt);
663 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
665 tree tem = valueize (rhs2);
666 if (tem)
667 rhs2 = tem;
669 *rcode = code;
670 ops[0] = rhs1;
671 ops[1] = rhs2;
672 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
674 case GIMPLE_TERNARY_RHS:
676 tree rhs1 = gimple_assign_rhs1 (stmt);
677 if (valueize && TREE_CODE (rhs1) == SSA_NAME)
679 tree tem = valueize (rhs1);
680 if (tem)
681 rhs1 = tem;
683 tree rhs2 = gimple_assign_rhs2 (stmt);
684 if (valueize && TREE_CODE (rhs2) == SSA_NAME)
686 tree tem = valueize (rhs2);
687 if (tem)
688 rhs2 = tem;
690 tree rhs3 = gimple_assign_rhs3 (stmt);
691 if (valueize && TREE_CODE (rhs3) == SSA_NAME)
693 tree tem = valueize (rhs3);
694 if (tem)
695 rhs3 = tem;
697 *rcode = code;
698 ops[0] = rhs1;
699 ops[1] = rhs2;
700 ops[2] = rhs3;
701 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
703 default:
704 gcc_unreachable ();
706 break;
709 case GIMPLE_CALL:
710 /* ??? This way we can't simplify calls with side-effects. */
711 if (gimple_call_lhs (stmt) != NULL_TREE)
713 tree fn = gimple_call_fn (stmt);
714 /* ??? Internal function support missing. */
715 if (!fn)
716 return false;
717 if (valueize && TREE_CODE (fn) == SSA_NAME)
719 tree tem = valueize (fn);
720 if (tem)
721 fn = tem;
723 if (!fn
724 || TREE_CODE (fn) != ADDR_EXPR
725 || TREE_CODE (TREE_OPERAND (fn, 0)) != FUNCTION_DECL
726 || DECL_BUILT_IN_CLASS (TREE_OPERAND (fn, 0)) != BUILT_IN_NORMAL
727 || !builtin_decl_implicit (DECL_FUNCTION_CODE (TREE_OPERAND (fn, 0)))
728 || !gimple_builtin_call_types_compatible_p (stmt,
729 TREE_OPERAND (fn, 0)))
730 return false;
732 tree decl = TREE_OPERAND (fn, 0);
733 tree type = TREE_TYPE (gimple_call_lhs (stmt));
734 switch (gimple_call_num_args (stmt))
736 case 1:
738 tree arg1 = gimple_call_arg (stmt, 0);
739 if (valueize && TREE_CODE (arg1) == SSA_NAME)
741 tree tem = valueize (arg1);
742 if (tem)
743 arg1 = tem;
745 *rcode = DECL_FUNCTION_CODE (decl);
746 ops[0] = arg1;
747 return gimple_resimplify1 (seq, rcode, type, ops, valueize);
749 case 2:
751 tree arg1 = gimple_call_arg (stmt, 0);
752 if (valueize && TREE_CODE (arg1) == SSA_NAME)
754 tree tem = valueize (arg1);
755 if (tem)
756 arg1 = tem;
758 tree arg2 = gimple_call_arg (stmt, 1);
759 if (valueize && TREE_CODE (arg2) == SSA_NAME)
761 tree tem = valueize (arg2);
762 if (tem)
763 arg2 = tem;
765 *rcode = DECL_FUNCTION_CODE (decl);
766 ops[0] = arg1;
767 ops[1] = arg2;
768 return gimple_resimplify2 (seq, rcode, type, ops, valueize);
770 case 3:
772 tree arg1 = gimple_call_arg (stmt, 0);
773 if (valueize && TREE_CODE (arg1) == SSA_NAME)
775 tree tem = valueize (arg1);
776 if (tem)
777 arg1 = tem;
779 tree arg2 = gimple_call_arg (stmt, 1);
780 if (valueize && TREE_CODE (arg2) == SSA_NAME)
782 tree tem = valueize (arg2);
783 if (tem)
784 arg2 = tem;
786 tree arg3 = gimple_call_arg (stmt, 2);
787 if (valueize && TREE_CODE (arg3) == SSA_NAME)
789 tree tem = valueize (arg3);
790 if (tem)
791 arg3 = tem;
793 *rcode = DECL_FUNCTION_CODE (decl);
794 ops[0] = arg1;
795 ops[1] = arg2;
796 ops[2] = arg3;
797 return gimple_resimplify3 (seq, rcode, type, ops, valueize);
799 default:
800 return false;
803 break;
805 case GIMPLE_COND:
807 tree lhs = gimple_cond_lhs (stmt);
808 if (valueize && TREE_CODE (lhs) == SSA_NAME)
810 tree tem = valueize (lhs);
811 if (tem)
812 lhs = tem;
814 tree rhs = gimple_cond_rhs (stmt);
815 if (valueize && TREE_CODE (rhs) == SSA_NAME)
817 tree tem = valueize (rhs);
818 if (tem)
819 rhs = tem;
821 *rcode = gimple_cond_code (stmt);
822 ops[0] = lhs;
823 ops[1] = rhs;
824 return gimple_resimplify2 (seq, rcode, boolean_type_node, ops, valueize);
827 default:
828 break;
831 return false;
835 /* Helper for the autogenerated code, valueize OP. */
837 inline tree
838 do_valueize (tree (*valueize)(tree), tree op)
840 if (valueize && TREE_CODE (op) == SSA_NAME)
841 return valueize (op);
842 return op;