1 /* Lower complex number operations to scalar operations.
2 Copyright (C) 2004-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
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
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/>. */
22 #include "coretypes.h"
27 #include "double-int.h"
35 #include "fold-const.h"
36 #include "stor-layout.h"
39 #include "hard-reg-set.h"
41 #include "dominance.h"
43 #include "basic-block.h"
44 #include "tree-ssa-alias.h"
45 #include "internal-fn.h"
47 #include "gimple-expr.h"
51 #include "gimple-iterator.h"
52 #include "gimplify-me.h"
53 #include "gimple-ssa.h"
55 #include "tree-phinodes.h"
56 #include "ssa-iterators.h"
57 #include "stringpool.h"
58 #include "tree-ssanames.h"
61 #include "statistics.h"
62 #include "fixed-value.h"
63 #include "insn-config.h"
74 #include "tree-iterator.h"
75 #include "tree-pass.h"
76 #include "tree-ssa-propagate.h"
77 #include "tree-hasher.h"
81 /* For each complex ssa name, a lattice value. We're interested in finding
82 out whether a complex number is degenerate in some way, having only real
83 or only complex parts. */
93 /* The type complex_lattice_t holds combinations of the above
95 typedef int complex_lattice_t;
97 #define PAIR(a, b) ((a) << 2 | (b))
100 static vec<complex_lattice_t> complex_lattice_values;
102 /* For each complex variable, a pair of variables for the components exists in
104 static int_tree_htab_type *complex_variable_components;
106 /* For each complex SSA_NAME, a pair of ssa names for the components. */
107 static vec<tree> complex_ssa_name_components;
109 /* Lookup UID in the complex_variable_components hashtable and return the
112 cvc_lookup (unsigned int uid)
114 struct int_tree_map in;
116 return complex_variable_components->find_with_hash (in, uid).to;
119 /* Insert the pair UID, TO into the complex_variable_components hashtable. */
122 cvc_insert (unsigned int uid, tree to)
128 loc = complex_variable_components->find_slot_with_hash (h, uid, INSERT);
133 /* Return true if T is not a zero constant. In the case of real values,
134 we're only interested in +0.0. */
137 some_nonzerop (tree t)
141 /* Operations with real or imaginary part of a complex number zero
142 cannot be treated the same as operations with a real or imaginary
143 operand if we care about the signs of zeros in the result. */
144 if (TREE_CODE (t) == REAL_CST && !flag_signed_zeros)
145 zerop = REAL_VALUES_IDENTICAL (TREE_REAL_CST (t), dconst0);
146 else if (TREE_CODE (t) == FIXED_CST)
147 zerop = fixed_zerop (t);
148 else if (TREE_CODE (t) == INTEGER_CST)
149 zerop = integer_zerop (t);
155 /* Compute a lattice value from the components of a complex type REAL
158 static complex_lattice_t
159 find_lattice_value_parts (tree real, tree imag)
162 complex_lattice_t ret;
164 r = some_nonzerop (real);
165 i = some_nonzerop (imag);
166 ret = r * ONLY_REAL + i * ONLY_IMAG;
168 /* ??? On occasion we could do better than mapping 0+0i to real, but we
169 certainly don't want to leave it UNINITIALIZED, which eventually gets
170 mapped to VARYING. */
171 if (ret == UNINITIALIZED)
178 /* Compute a lattice value from gimple_val T. */
180 static complex_lattice_t
181 find_lattice_value (tree t)
185 switch (TREE_CODE (t))
188 return complex_lattice_values[SSA_NAME_VERSION (t)];
191 real = TREE_REALPART (t);
192 imag = TREE_IMAGPART (t);
199 return find_lattice_value_parts (real, imag);
202 /* Determine if LHS is something for which we're interested in seeing
203 simulation results. */
206 is_complex_reg (tree lhs)
208 return TREE_CODE (TREE_TYPE (lhs)) == COMPLEX_TYPE && is_gimple_reg (lhs);
211 /* Mark the incoming parameters to the function as VARYING. */
214 init_parameter_lattice_values (void)
218 for (parm = DECL_ARGUMENTS (cfun->decl); parm ; parm = DECL_CHAIN (parm))
219 if (is_complex_reg (parm)
220 && (ssa_name = ssa_default_def (cfun, parm)) != NULL_TREE)
221 complex_lattice_values[SSA_NAME_VERSION (ssa_name)] = VARYING;
224 /* Initialize simulation state for each statement. Return false if we
225 found no statements we want to simulate, and thus there's nothing
226 for the entire pass to do. */
229 init_dont_simulate_again (void)
232 bool saw_a_complex_op = false;
234 FOR_EACH_BB_FN (bb, cfun)
236 for (gphi_iterator gsi = gsi_start_phis (bb); !gsi_end_p (gsi);
239 gphi *phi = gsi.phi ();
240 prop_set_simulate_again (phi,
241 is_complex_reg (gimple_phi_result (phi)));
244 for (gimple_stmt_iterator gsi = gsi_start_bb (bb); !gsi_end_p (gsi);
251 stmt = gsi_stmt (gsi);
252 op0 = op1 = NULL_TREE;
254 /* Most control-altering statements must be initially
255 simulated, else we won't cover the entire cfg. */
256 sim_again_p = stmt_ends_bb_p (stmt);
258 switch (gimple_code (stmt))
261 if (gimple_call_lhs (stmt))
262 sim_again_p = is_complex_reg (gimple_call_lhs (stmt));
266 sim_again_p = is_complex_reg (gimple_assign_lhs (stmt));
267 if (gimple_assign_rhs_code (stmt) == REALPART_EXPR
268 || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR)
269 op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
271 op0 = gimple_assign_rhs1 (stmt);
272 if (gimple_num_ops (stmt) > 2)
273 op1 = gimple_assign_rhs2 (stmt);
277 op0 = gimple_cond_lhs (stmt);
278 op1 = gimple_cond_rhs (stmt);
286 switch (gimple_expr_code (stmt))
298 if (TREE_CODE (TREE_TYPE (op0)) == COMPLEX_TYPE
299 || TREE_CODE (TREE_TYPE (op1)) == COMPLEX_TYPE)
300 saw_a_complex_op = true;
305 if (TREE_CODE (TREE_TYPE (op0)) == COMPLEX_TYPE)
306 saw_a_complex_op = true;
311 /* The total store transformation performed during
312 gimplification creates such uninitialized loads
313 and we need to lower the statement to be able
315 if (TREE_CODE (op0) == SSA_NAME
316 && ssa_undefined_value_p (op0))
317 saw_a_complex_op = true;
324 prop_set_simulate_again (stmt, sim_again_p);
328 return saw_a_complex_op;
332 /* Evaluate statement STMT against the complex lattice defined above. */
334 static enum ssa_prop_result
335 complex_visit_stmt (gimple stmt, edge *taken_edge_p ATTRIBUTE_UNUSED,
338 complex_lattice_t new_l, old_l, op1_l, op2_l;
342 lhs = gimple_get_lhs (stmt);
343 /* Skip anything but GIMPLE_ASSIGN and GIMPLE_CALL with a lhs. */
345 return SSA_PROP_VARYING;
347 /* These conditions should be satisfied due to the initial filter
348 set up in init_dont_simulate_again. */
349 gcc_assert (TREE_CODE (lhs) == SSA_NAME);
350 gcc_assert (TREE_CODE (TREE_TYPE (lhs)) == COMPLEX_TYPE);
353 ver = SSA_NAME_VERSION (lhs);
354 old_l = complex_lattice_values[ver];
356 switch (gimple_expr_code (stmt))
360 new_l = find_lattice_value (gimple_assign_rhs1 (stmt));
364 new_l = find_lattice_value_parts (gimple_assign_rhs1 (stmt),
365 gimple_assign_rhs2 (stmt));
370 op1_l = find_lattice_value (gimple_assign_rhs1 (stmt));
371 op2_l = find_lattice_value (gimple_assign_rhs2 (stmt));
373 /* We've set up the lattice values such that IOR neatly
375 new_l = op1_l | op2_l;
384 op1_l = find_lattice_value (gimple_assign_rhs1 (stmt));
385 op2_l = find_lattice_value (gimple_assign_rhs2 (stmt));
387 /* Obviously, if either varies, so does the result. */
388 if (op1_l == VARYING || op2_l == VARYING)
390 /* Don't prematurely promote variables if we've not yet seen
392 else if (op1_l == UNINITIALIZED)
394 else if (op2_l == UNINITIALIZED)
398 /* At this point both numbers have only one component. If the
399 numbers are of opposite kind, the result is imaginary,
400 otherwise the result is real. The add/subtract translates
401 the real/imag from/to 0/1; the ^ performs the comparison. */
402 new_l = ((op1_l - ONLY_REAL) ^ (op2_l - ONLY_REAL)) + ONLY_REAL;
404 /* Don't allow the lattice value to flip-flop indefinitely. */
411 new_l = find_lattice_value (gimple_assign_rhs1 (stmt));
419 /* If nothing changed this round, let the propagator know. */
421 return SSA_PROP_NOT_INTERESTING;
423 complex_lattice_values[ver] = new_l;
424 return new_l == VARYING ? SSA_PROP_VARYING : SSA_PROP_INTERESTING;
427 /* Evaluate a PHI node against the complex lattice defined above. */
429 static enum ssa_prop_result
430 complex_visit_phi (gphi *phi)
432 complex_lattice_t new_l, old_l;
437 lhs = gimple_phi_result (phi);
439 /* This condition should be satisfied due to the initial filter
440 set up in init_dont_simulate_again. */
441 gcc_assert (TREE_CODE (TREE_TYPE (lhs)) == COMPLEX_TYPE);
443 /* We've set up the lattice values such that IOR neatly models PHI meet. */
444 new_l = UNINITIALIZED;
445 for (i = gimple_phi_num_args (phi) - 1; i >= 0; --i)
446 new_l |= find_lattice_value (gimple_phi_arg_def (phi, i));
448 ver = SSA_NAME_VERSION (lhs);
449 old_l = complex_lattice_values[ver];
452 return SSA_PROP_NOT_INTERESTING;
454 complex_lattice_values[ver] = new_l;
455 return new_l == VARYING ? SSA_PROP_VARYING : SSA_PROP_INTERESTING;
458 /* Create one backing variable for a complex component of ORIG. */
461 create_one_component_var (tree type, tree orig, const char *prefix,
462 const char *suffix, enum tree_code code)
464 tree r = create_tmp_var (type, prefix);
466 DECL_SOURCE_LOCATION (r) = DECL_SOURCE_LOCATION (orig);
467 DECL_ARTIFICIAL (r) = 1;
469 if (DECL_NAME (orig) && !DECL_IGNORED_P (orig))
471 const char *name = IDENTIFIER_POINTER (DECL_NAME (orig));
473 DECL_NAME (r) = get_identifier (ACONCAT ((name, suffix, NULL)));
475 SET_DECL_DEBUG_EXPR (r, build1 (code, type, orig));
476 DECL_HAS_DEBUG_EXPR_P (r) = 1;
477 DECL_IGNORED_P (r) = 0;
478 TREE_NO_WARNING (r) = TREE_NO_WARNING (orig);
482 DECL_IGNORED_P (r) = 1;
483 TREE_NO_WARNING (r) = 1;
489 /* Retrieve a value for a complex component of VAR. */
492 get_component_var (tree var, bool imag_p)
494 size_t decl_index = DECL_UID (var) * 2 + imag_p;
495 tree ret = cvc_lookup (decl_index);
499 ret = create_one_component_var (TREE_TYPE (TREE_TYPE (var)), var,
500 imag_p ? "CI" : "CR",
501 imag_p ? "$imag" : "$real",
502 imag_p ? IMAGPART_EXPR : REALPART_EXPR);
503 cvc_insert (decl_index, ret);
509 /* Retrieve a value for a complex component of SSA_NAME. */
512 get_component_ssa_name (tree ssa_name, bool imag_p)
514 complex_lattice_t lattice = find_lattice_value (ssa_name);
515 size_t ssa_name_index;
518 if (lattice == (imag_p ? ONLY_REAL : ONLY_IMAG))
520 tree inner_type = TREE_TYPE (TREE_TYPE (ssa_name));
521 if (SCALAR_FLOAT_TYPE_P (inner_type))
522 return build_real (inner_type, dconst0);
524 return build_int_cst (inner_type, 0);
527 ssa_name_index = SSA_NAME_VERSION (ssa_name) * 2 + imag_p;
528 ret = complex_ssa_name_components[ssa_name_index];
531 if (SSA_NAME_VAR (ssa_name))
532 ret = get_component_var (SSA_NAME_VAR (ssa_name), imag_p);
534 ret = TREE_TYPE (TREE_TYPE (ssa_name));
535 ret = make_ssa_name (ret);
537 /* Copy some properties from the original. In particular, whether it
538 is used in an abnormal phi, and whether it's uninitialized. */
539 SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ret)
540 = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ssa_name);
541 if (SSA_NAME_IS_DEFAULT_DEF (ssa_name)
542 && TREE_CODE (SSA_NAME_VAR (ssa_name)) == VAR_DECL)
544 SSA_NAME_DEF_STMT (ret) = SSA_NAME_DEF_STMT (ssa_name);
545 set_ssa_default_def (cfun, SSA_NAME_VAR (ret), ret);
548 complex_ssa_name_components[ssa_name_index] = ret;
554 /* Set a value for a complex component of SSA_NAME, return a
555 gimple_seq of stuff that needs doing. */
558 set_component_ssa_name (tree ssa_name, bool imag_p, tree value)
560 complex_lattice_t lattice = find_lattice_value (ssa_name);
561 size_t ssa_name_index;
566 /* We know the value must be zero, else there's a bug in our lattice
567 analysis. But the value may well be a variable known to contain
568 zero. We should be safe ignoring it. */
569 if (lattice == (imag_p ? ONLY_REAL : ONLY_IMAG))
572 /* If we've already assigned an SSA_NAME to this component, then this
573 means that our walk of the basic blocks found a use before the set.
574 This is fine. Now we should create an initialization for the value
575 we created earlier. */
576 ssa_name_index = SSA_NAME_VERSION (ssa_name) * 2 + imag_p;
577 comp = complex_ssa_name_components[ssa_name_index];
581 /* If we've nothing assigned, and the value we're given is already stable,
582 then install that as the value for this SSA_NAME. This preemptively
583 copy-propagates the value, which avoids unnecessary memory allocation. */
584 else if (is_gimple_min_invariant (value)
585 && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ssa_name))
587 complex_ssa_name_components[ssa_name_index] = value;
590 else if (TREE_CODE (value) == SSA_NAME
591 && !SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ssa_name))
593 /* Replace an anonymous base value with the variable from cvc_lookup.
594 This should result in better debug info. */
595 if (SSA_NAME_VAR (ssa_name)
596 && (!SSA_NAME_VAR (value) || DECL_IGNORED_P (SSA_NAME_VAR (value)))
597 && !DECL_IGNORED_P (SSA_NAME_VAR (ssa_name)))
599 comp = get_component_var (SSA_NAME_VAR (ssa_name), imag_p);
600 replace_ssa_name_symbol (value, comp);
603 complex_ssa_name_components[ssa_name_index] = value;
607 /* Finally, we need to stabilize the result by installing the value into
610 comp = get_component_ssa_name (ssa_name, imag_p);
612 /* Do all the work to assign VALUE to COMP. */
614 value = force_gimple_operand (value, &list, false, NULL);
615 last = gimple_build_assign (comp, value);
616 gimple_seq_add_stmt (&list, last);
617 gcc_assert (SSA_NAME_DEF_STMT (comp) == last);
622 /* Extract the real or imaginary part of a complex variable or constant.
623 Make sure that it's a proper gimple_val and gimplify it if not.
624 Emit any new code before gsi. */
627 extract_component (gimple_stmt_iterator *gsi, tree t, bool imagpart_p,
630 switch (TREE_CODE (t))
633 return imagpart_p ? TREE_IMAGPART (t) : TREE_REALPART (t);
643 case VIEW_CONVERT_EXPR:
646 tree inner_type = TREE_TYPE (TREE_TYPE (t));
648 t = build1 ((imagpart_p ? IMAGPART_EXPR : REALPART_EXPR),
649 inner_type, unshare_expr (t));
652 t = force_gimple_operand_gsi (gsi, t, true, NULL, true,
659 return get_component_ssa_name (t, imagpart_p);
666 /* Update the complex components of the ssa name on the lhs of STMT. */
669 update_complex_components (gimple_stmt_iterator *gsi, gimple stmt, tree r,
675 lhs = gimple_get_lhs (stmt);
677 list = set_component_ssa_name (lhs, false, r);
679 gsi_insert_seq_after (gsi, list, GSI_CONTINUE_LINKING);
681 list = set_component_ssa_name (lhs, true, i);
683 gsi_insert_seq_after (gsi, list, GSI_CONTINUE_LINKING);
687 update_complex_components_on_edge (edge e, tree lhs, tree r, tree i)
691 list = set_component_ssa_name (lhs, false, r);
693 gsi_insert_seq_on_edge (e, list);
695 list = set_component_ssa_name (lhs, true, i);
697 gsi_insert_seq_on_edge (e, list);
701 /* Update an assignment to a complex variable in place. */
704 update_complex_assignment (gimple_stmt_iterator *gsi, tree r, tree i)
708 gimple_assign_set_rhs_with_ops (gsi, COMPLEX_EXPR, r, i);
709 stmt = gsi_stmt (*gsi);
711 if (maybe_clean_eh_stmt (stmt))
712 gimple_purge_dead_eh_edges (gimple_bb (stmt));
714 if (gimple_in_ssa_p (cfun))
715 update_complex_components (gsi, gsi_stmt (*gsi), r, i);
719 /* Generate code at the entry point of the function to initialize the
720 component variables for a complex parameter. */
723 update_parameter_components (void)
725 edge entry_edge = single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun));
728 for (parm = DECL_ARGUMENTS (cfun->decl); parm ; parm = DECL_CHAIN (parm))
730 tree type = TREE_TYPE (parm);
733 if (TREE_CODE (type) != COMPLEX_TYPE || !is_gimple_reg (parm))
736 type = TREE_TYPE (type);
737 ssa_name = ssa_default_def (cfun, parm);
741 r = build1 (REALPART_EXPR, type, ssa_name);
742 i = build1 (IMAGPART_EXPR, type, ssa_name);
743 update_complex_components_on_edge (entry_edge, ssa_name, r, i);
747 /* Generate code to set the component variables of a complex variable
748 to match the PHI statements in block BB. */
751 update_phi_components (basic_block bb)
755 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
757 gphi *phi = gsi.phi ();
759 if (is_complex_reg (gimple_phi_result (phi)))
762 gimple pr = NULL, pi = NULL;
765 lr = get_component_ssa_name (gimple_phi_result (phi), false);
766 if (TREE_CODE (lr) == SSA_NAME)
767 pr = create_phi_node (lr, bb);
769 li = get_component_ssa_name (gimple_phi_result (phi), true);
770 if (TREE_CODE (li) == SSA_NAME)
771 pi = create_phi_node (li, bb);
773 for (i = 0, n = gimple_phi_num_args (phi); i < n; ++i)
775 tree comp, arg = gimple_phi_arg_def (phi, i);
778 comp = extract_component (NULL, arg, false, false);
779 SET_PHI_ARG_DEF (pr, i, comp);
783 comp = extract_component (NULL, arg, true, false);
784 SET_PHI_ARG_DEF (pi, i, comp);
791 /* Expand a complex move to scalars. */
794 expand_complex_move (gimple_stmt_iterator *gsi, tree type)
796 tree inner_type = TREE_TYPE (type);
798 gimple stmt = gsi_stmt (*gsi);
800 if (is_gimple_assign (stmt))
802 lhs = gimple_assign_lhs (stmt);
803 if (gimple_num_ops (stmt) == 2)
804 rhs = gimple_assign_rhs1 (stmt);
808 else if (is_gimple_call (stmt))
810 lhs = gimple_call_lhs (stmt);
816 if (TREE_CODE (lhs) == SSA_NAME)
818 if (is_ctrl_altering_stmt (stmt))
822 /* The value is not assigned on the exception edges, so we need not
823 concern ourselves there. We do need to update on the fallthru
825 e = find_fallthru_edge (gsi_bb (*gsi)->succs);
829 r = build1 (REALPART_EXPR, inner_type, lhs);
830 i = build1 (IMAGPART_EXPR, inner_type, lhs);
831 update_complex_components_on_edge (e, lhs, r, i);
833 else if (is_gimple_call (stmt)
834 || gimple_has_side_effects (stmt)
835 || gimple_assign_rhs_code (stmt) == PAREN_EXPR)
837 r = build1 (REALPART_EXPR, inner_type, lhs);
838 i = build1 (IMAGPART_EXPR, inner_type, lhs);
839 update_complex_components (gsi, stmt, r, i);
843 if (gimple_assign_rhs_code (stmt) != COMPLEX_EXPR)
845 r = extract_component (gsi, rhs, 0, true);
846 i = extract_component (gsi, rhs, 1, true);
850 r = gimple_assign_rhs1 (stmt);
851 i = gimple_assign_rhs2 (stmt);
853 update_complex_assignment (gsi, r, i);
856 else if (rhs && TREE_CODE (rhs) == SSA_NAME && !TREE_SIDE_EFFECTS (lhs))
862 loc = gimple_location (stmt);
863 r = extract_component (gsi, rhs, 0, false);
864 i = extract_component (gsi, rhs, 1, false);
866 x = build1 (REALPART_EXPR, inner_type, unshare_expr (lhs));
867 t = gimple_build_assign (x, r);
868 gimple_set_location (t, loc);
869 gsi_insert_before (gsi, t, GSI_SAME_STMT);
871 if (stmt == gsi_stmt (*gsi))
873 x = build1 (IMAGPART_EXPR, inner_type, unshare_expr (lhs));
874 gimple_assign_set_lhs (stmt, x);
875 gimple_assign_set_rhs1 (stmt, i);
879 x = build1 (IMAGPART_EXPR, inner_type, unshare_expr (lhs));
880 t = gimple_build_assign (x, i);
881 gimple_set_location (t, loc);
882 gsi_insert_before (gsi, t, GSI_SAME_STMT);
884 stmt = gsi_stmt (*gsi);
885 gcc_assert (gimple_code (stmt) == GIMPLE_RETURN);
886 gimple_return_set_retval (as_a <greturn *> (stmt), lhs);
893 /* Expand complex addition to scalars:
894 a + b = (ar + br) + i(ai + bi)
895 a - b = (ar - br) + i(ai + bi)
899 expand_complex_addition (gimple_stmt_iterator *gsi, tree inner_type,
900 tree ar, tree ai, tree br, tree bi,
902 complex_lattice_t al, complex_lattice_t bl)
906 switch (PAIR (al, bl))
908 case PAIR (ONLY_REAL, ONLY_REAL):
909 rr = gimplify_build2 (gsi, code, inner_type, ar, br);
913 case PAIR (ONLY_REAL, ONLY_IMAG):
915 if (code == MINUS_EXPR)
916 ri = gimplify_build2 (gsi, MINUS_EXPR, inner_type, ai, bi);
921 case PAIR (ONLY_IMAG, ONLY_REAL):
922 if (code == MINUS_EXPR)
923 rr = gimplify_build2 (gsi, MINUS_EXPR, inner_type, ar, br);
929 case PAIR (ONLY_IMAG, ONLY_IMAG):
931 ri = gimplify_build2 (gsi, code, inner_type, ai, bi);
934 case PAIR (VARYING, ONLY_REAL):
935 rr = gimplify_build2 (gsi, code, inner_type, ar, br);
939 case PAIR (VARYING, ONLY_IMAG):
941 ri = gimplify_build2 (gsi, code, inner_type, ai, bi);
944 case PAIR (ONLY_REAL, VARYING):
945 if (code == MINUS_EXPR)
947 rr = gimplify_build2 (gsi, code, inner_type, ar, br);
951 case PAIR (ONLY_IMAG, VARYING):
952 if (code == MINUS_EXPR)
955 ri = gimplify_build2 (gsi, code, inner_type, ai, bi);
958 case PAIR (VARYING, VARYING):
960 rr = gimplify_build2 (gsi, code, inner_type, ar, br);
961 ri = gimplify_build2 (gsi, code, inner_type, ai, bi);
968 update_complex_assignment (gsi, rr, ri);
971 /* Expand a complex multiplication or division to a libcall to the c99
972 compliant routines. */
975 expand_complex_libcall (gimple_stmt_iterator *gsi, tree ar, tree ai,
976 tree br, tree bi, enum tree_code code)
979 enum built_in_function bcode;
984 old_stmt = gsi_stmt (*gsi);
985 lhs = gimple_assign_lhs (old_stmt);
986 type = TREE_TYPE (lhs);
988 mode = TYPE_MODE (type);
989 gcc_assert (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT);
991 if (code == MULT_EXPR)
992 bcode = ((enum built_in_function)
993 (BUILT_IN_COMPLEX_MUL_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
994 else if (code == RDIV_EXPR)
995 bcode = ((enum built_in_function)
996 (BUILT_IN_COMPLEX_DIV_MIN + mode - MIN_MODE_COMPLEX_FLOAT));
999 fn = builtin_decl_explicit (bcode);
1001 stmt = gimple_build_call (fn, 4, ar, ai, br, bi);
1002 gimple_call_set_lhs (stmt, lhs);
1004 gsi_replace (gsi, stmt, false);
1006 if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt))
1007 gimple_purge_dead_eh_edges (gsi_bb (*gsi));
1009 if (gimple_in_ssa_p (cfun))
1011 type = TREE_TYPE (type);
1012 update_complex_components (gsi, stmt,
1013 build1 (REALPART_EXPR, type, lhs),
1014 build1 (IMAGPART_EXPR, type, lhs));
1015 SSA_NAME_DEF_STMT (lhs) = stmt;
1019 /* Expand complex multiplication to scalars:
1020 a * b = (ar*br - ai*bi) + i(ar*bi + br*ai)
1024 expand_complex_multiplication (gimple_stmt_iterator *gsi, tree inner_type,
1025 tree ar, tree ai, tree br, tree bi,
1026 complex_lattice_t al, complex_lattice_t bl)
1032 complex_lattice_t tl;
1033 rr = ar, ar = br, br = rr;
1034 ri = ai, ai = bi, bi = ri;
1035 tl = al, al = bl, bl = tl;
1038 switch (PAIR (al, bl))
1040 case PAIR (ONLY_REAL, ONLY_REAL):
1041 rr = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, br);
1045 case PAIR (ONLY_IMAG, ONLY_REAL):
1047 if (TREE_CODE (ai) == REAL_CST
1048 && REAL_VALUES_IDENTICAL (TREE_REAL_CST (ai), dconst1))
1051 ri = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, br);
1054 case PAIR (ONLY_IMAG, ONLY_IMAG):
1055 rr = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, bi);
1056 rr = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, rr);
1060 case PAIR (VARYING, ONLY_REAL):
1061 rr = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, br);
1062 ri = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, br);
1065 case PAIR (VARYING, ONLY_IMAG):
1066 rr = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, bi);
1067 rr = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, rr);
1068 ri = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, bi);
1071 case PAIR (VARYING, VARYING):
1072 if (flag_complex_method == 2 && SCALAR_FLOAT_TYPE_P (inner_type))
1074 expand_complex_libcall (gsi, ar, ai, br, bi, MULT_EXPR);
1079 tree t1, t2, t3, t4;
1081 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, br);
1082 t2 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, bi);
1083 t3 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, bi);
1085 /* Avoid expanding redundant multiplication for the common
1086 case of squaring a complex number. */
1087 if (ar == br && ai == bi)
1090 t4 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, br);
1092 rr = gimplify_build2 (gsi, MINUS_EXPR, inner_type, t1, t2);
1093 ri = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t3, t4);
1101 update_complex_assignment (gsi, rr, ri);
1104 /* Keep this algorithm in sync with fold-const.c:const_binop().
1106 Expand complex division to scalars, straightforward algorithm.
1107 a / b = ((ar*br + ai*bi)/t) + i((ai*br - ar*bi)/t)
1112 expand_complex_div_straight (gimple_stmt_iterator *gsi, tree inner_type,
1113 tree ar, tree ai, tree br, tree bi,
1114 enum tree_code code)
1116 tree rr, ri, div, t1, t2, t3;
1118 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, br, br);
1119 t2 = gimplify_build2 (gsi, MULT_EXPR, inner_type, bi, bi);
1120 div = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t1, t2);
1122 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, br);
1123 t2 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, bi);
1124 t3 = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t1, t2);
1125 rr = gimplify_build2 (gsi, code, inner_type, t3, div);
1127 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, br);
1128 t2 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, bi);
1129 t3 = gimplify_build2 (gsi, MINUS_EXPR, inner_type, t1, t2);
1130 ri = gimplify_build2 (gsi, code, inner_type, t3, div);
1132 update_complex_assignment (gsi, rr, ri);
1135 /* Keep this algorithm in sync with fold-const.c:const_binop().
1137 Expand complex division to scalars, modified algorithm to minimize
1138 overflow with wide input ranges. */
1141 expand_complex_div_wide (gimple_stmt_iterator *gsi, tree inner_type,
1142 tree ar, tree ai, tree br, tree bi,
1143 enum tree_code code)
1145 tree rr, ri, ratio, div, t1, t2, tr, ti, compare;
1146 basic_block bb_cond, bb_true, bb_false, bb_join;
1149 /* Examine |br| < |bi|, and branch. */
1150 t1 = gimplify_build1 (gsi, ABS_EXPR, inner_type, br);
1151 t2 = gimplify_build1 (gsi, ABS_EXPR, inner_type, bi);
1152 compare = fold_build2_loc (gimple_location (gsi_stmt (*gsi)),
1153 LT_EXPR, boolean_type_node, t1, t2);
1154 STRIP_NOPS (compare);
1156 bb_cond = bb_true = bb_false = bb_join = NULL;
1157 rr = ri = tr = ti = NULL;
1158 if (TREE_CODE (compare) != INTEGER_CST)
1164 tmp = create_tmp_var (boolean_type_node);
1165 stmt = gimple_build_assign (tmp, compare);
1166 if (gimple_in_ssa_p (cfun))
1168 tmp = make_ssa_name (tmp, stmt);
1169 gimple_assign_set_lhs (stmt, tmp);
1172 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
1174 cond = fold_build2_loc (gimple_location (stmt),
1175 EQ_EXPR, boolean_type_node, tmp, boolean_true_node);
1176 stmt = gimple_build_cond_from_tree (cond, NULL_TREE, NULL_TREE);
1177 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
1179 /* Split the original block, and create the TRUE and FALSE blocks. */
1180 e = split_block (gsi_bb (*gsi), stmt);
1183 bb_true = create_empty_bb (bb_cond);
1184 bb_false = create_empty_bb (bb_true);
1186 /* Wire the blocks together. */
1187 e->flags = EDGE_TRUE_VALUE;
1188 redirect_edge_succ (e, bb_true);
1189 make_edge (bb_cond, bb_false, EDGE_FALSE_VALUE);
1190 make_edge (bb_true, bb_join, EDGE_FALLTHRU);
1191 make_edge (bb_false, bb_join, EDGE_FALLTHRU);
1192 add_bb_to_loop (bb_true, bb_cond->loop_father);
1193 add_bb_to_loop (bb_false, bb_cond->loop_father);
1195 /* Update dominance info. Note that bb_join's data was
1196 updated by split_block. */
1197 if (dom_info_available_p (CDI_DOMINATORS))
1199 set_immediate_dominator (CDI_DOMINATORS, bb_true, bb_cond);
1200 set_immediate_dominator (CDI_DOMINATORS, bb_false, bb_cond);
1203 rr = create_tmp_reg (inner_type);
1204 ri = create_tmp_reg (inner_type);
1207 /* In the TRUE branch, we compute
1209 div = (br * ratio) + bi;
1210 tr = (ar * ratio) + ai;
1211 ti = (ai * ratio) - ar;
1214 if (bb_true || integer_nonzerop (compare))
1218 *gsi = gsi_last_bb (bb_true);
1219 gsi_insert_after (gsi, gimple_build_nop (), GSI_NEW_STMT);
1222 ratio = gimplify_build2 (gsi, code, inner_type, br, bi);
1224 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, br, ratio);
1225 div = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t1, bi);
1227 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, ratio);
1228 tr = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t1, ai);
1230 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, ratio);
1231 ti = gimplify_build2 (gsi, MINUS_EXPR, inner_type, t1, ar);
1233 tr = gimplify_build2 (gsi, code, inner_type, tr, div);
1234 ti = gimplify_build2 (gsi, code, inner_type, ti, div);
1238 stmt = gimple_build_assign (rr, tr);
1239 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
1240 stmt = gimple_build_assign (ri, ti);
1241 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
1242 gsi_remove (gsi, true);
1246 /* In the FALSE branch, we compute
1248 divisor = (d * ratio) + c;
1249 tr = (b * ratio) + a;
1250 ti = b - (a * ratio);
1253 if (bb_false || integer_zerop (compare))
1257 *gsi = gsi_last_bb (bb_false);
1258 gsi_insert_after (gsi, gimple_build_nop (), GSI_NEW_STMT);
1261 ratio = gimplify_build2 (gsi, code, inner_type, bi, br);
1263 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, bi, ratio);
1264 div = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t1, br);
1266 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ai, ratio);
1267 tr = gimplify_build2 (gsi, PLUS_EXPR, inner_type, t1, ar);
1269 t1 = gimplify_build2 (gsi, MULT_EXPR, inner_type, ar, ratio);
1270 ti = gimplify_build2 (gsi, MINUS_EXPR, inner_type, ai, t1);
1272 tr = gimplify_build2 (gsi, code, inner_type, tr, div);
1273 ti = gimplify_build2 (gsi, code, inner_type, ti, div);
1277 stmt = gimple_build_assign (rr, tr);
1278 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
1279 stmt = gimple_build_assign (ri, ti);
1280 gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
1281 gsi_remove (gsi, true);
1286 *gsi = gsi_start_bb (bb_join);
1290 update_complex_assignment (gsi, rr, ri);
1293 /* Expand complex division to scalars. */
1296 expand_complex_division (gimple_stmt_iterator *gsi, tree inner_type,
1297 tree ar, tree ai, tree br, tree bi,
1298 enum tree_code code,
1299 complex_lattice_t al, complex_lattice_t bl)
1303 switch (PAIR (al, bl))
1305 case PAIR (ONLY_REAL, ONLY_REAL):
1306 rr = gimplify_build2 (gsi, code, inner_type, ar, br);
1310 case PAIR (ONLY_REAL, ONLY_IMAG):
1312 ri = gimplify_build2 (gsi, code, inner_type, ar, bi);
1313 ri = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, ri);
1316 case PAIR (ONLY_IMAG, ONLY_REAL):
1318 ri = gimplify_build2 (gsi, code, inner_type, ai, br);
1321 case PAIR (ONLY_IMAG, ONLY_IMAG):
1322 rr = gimplify_build2 (gsi, code, inner_type, ai, bi);
1326 case PAIR (VARYING, ONLY_REAL):
1327 rr = gimplify_build2 (gsi, code, inner_type, ar, br);
1328 ri = gimplify_build2 (gsi, code, inner_type, ai, br);
1331 case PAIR (VARYING, ONLY_IMAG):
1332 rr = gimplify_build2 (gsi, code, inner_type, ai, bi);
1333 ri = gimplify_build2 (gsi, code, inner_type, ar, bi);
1334 ri = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, ri);
1336 case PAIR (ONLY_REAL, VARYING):
1337 case PAIR (ONLY_IMAG, VARYING):
1338 case PAIR (VARYING, VARYING):
1339 switch (flag_complex_method)
1342 /* straightforward implementation of complex divide acceptable. */
1343 expand_complex_div_straight (gsi, inner_type, ar, ai, br, bi, code);
1347 if (SCALAR_FLOAT_TYPE_P (inner_type))
1349 expand_complex_libcall (gsi, ar, ai, br, bi, code);
1355 /* wide ranges of inputs must work for complex divide. */
1356 expand_complex_div_wide (gsi, inner_type, ar, ai, br, bi, code);
1368 update_complex_assignment (gsi, rr, ri);
1371 /* Expand complex negation to scalars:
1376 expand_complex_negation (gimple_stmt_iterator *gsi, tree inner_type,
1381 rr = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, ar);
1382 ri = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, ai);
1384 update_complex_assignment (gsi, rr, ri);
1387 /* Expand complex conjugate to scalars:
1392 expand_complex_conjugate (gimple_stmt_iterator *gsi, tree inner_type,
1397 ri = gimplify_build1 (gsi, NEGATE_EXPR, inner_type, ai);
1399 update_complex_assignment (gsi, ar, ri);
1402 /* Expand complex comparison (EQ or NE only). */
1405 expand_complex_comparison (gimple_stmt_iterator *gsi, tree ar, tree ai,
1406 tree br, tree bi, enum tree_code code)
1408 tree cr, ci, cc, type;
1411 cr = gimplify_build2 (gsi, code, boolean_type_node, ar, br);
1412 ci = gimplify_build2 (gsi, code, boolean_type_node, ai, bi);
1413 cc = gimplify_build2 (gsi,
1414 (code == EQ_EXPR ? TRUTH_AND_EXPR : TRUTH_OR_EXPR),
1415 boolean_type_node, cr, ci);
1417 stmt = gsi_stmt (*gsi);
1419 switch (gimple_code (stmt))
1423 greturn *return_stmt = as_a <greturn *> (stmt);
1424 type = TREE_TYPE (gimple_return_retval (return_stmt));
1425 gimple_return_set_retval (return_stmt, fold_convert (type, cc));
1430 type = TREE_TYPE (gimple_assign_lhs (stmt));
1431 gimple_assign_set_rhs_from_tree (gsi, fold_convert (type, cc));
1432 stmt = gsi_stmt (*gsi);
1437 gcond *cond_stmt = as_a <gcond *> (stmt);
1438 gimple_cond_set_code (cond_stmt, EQ_EXPR);
1439 gimple_cond_set_lhs (cond_stmt, cc);
1440 gimple_cond_set_rhs (cond_stmt, boolean_true_node);
1451 /* Expand inline asm that sets some complex SSA_NAMEs. */
1454 expand_complex_asm (gimple_stmt_iterator *gsi)
1456 gasm *stmt = as_a <gasm *> (gsi_stmt (*gsi));
1459 for (i = 0; i < gimple_asm_noutputs (stmt); ++i)
1461 tree link = gimple_asm_output_op (stmt, i);
1462 tree op = TREE_VALUE (link);
1463 if (TREE_CODE (op) == SSA_NAME
1464 && TREE_CODE (TREE_TYPE (op)) == COMPLEX_TYPE)
1466 tree type = TREE_TYPE (op);
1467 tree inner_type = TREE_TYPE (type);
1468 tree r = build1 (REALPART_EXPR, inner_type, op);
1469 tree i = build1 (IMAGPART_EXPR, inner_type, op);
1470 gimple_seq list = set_component_ssa_name (op, false, r);
1473 gsi_insert_seq_after (gsi, list, GSI_CONTINUE_LINKING);
1475 list = set_component_ssa_name (op, true, i);
1477 gsi_insert_seq_after (gsi, list, GSI_CONTINUE_LINKING);
1482 /* Process one statement. If we identify a complex operation, expand it. */
1485 expand_complex_operations_1 (gimple_stmt_iterator *gsi)
1487 gimple stmt = gsi_stmt (*gsi);
1488 tree type, inner_type, lhs;
1489 tree ac, ar, ai, bc, br, bi;
1490 complex_lattice_t al, bl;
1491 enum tree_code code;
1493 if (gimple_code (stmt) == GIMPLE_ASM)
1495 expand_complex_asm (gsi);
1499 lhs = gimple_get_lhs (stmt);
1500 if (!lhs && gimple_code (stmt) != GIMPLE_COND)
1503 type = TREE_TYPE (gimple_op (stmt, 0));
1504 code = gimple_expr_code (stmt);
1506 /* Initial filter for operations we handle. */
1512 case TRUNC_DIV_EXPR:
1514 case FLOOR_DIV_EXPR:
1515 case ROUND_DIV_EXPR:
1519 if (TREE_CODE (type) != COMPLEX_TYPE)
1521 inner_type = TREE_TYPE (type);
1526 /* Note, both GIMPLE_ASSIGN and GIMPLE_COND may have an EQ_EXPR
1527 subcode, so we need to access the operands using gimple_op. */
1528 inner_type = TREE_TYPE (gimple_op (stmt, 1));
1529 if (TREE_CODE (inner_type) != COMPLEX_TYPE)
1537 /* GIMPLE_COND may also fallthru here, but we do not need to
1538 do anything with it. */
1539 if (gimple_code (stmt) == GIMPLE_COND)
1542 if (TREE_CODE (type) == COMPLEX_TYPE)
1543 expand_complex_move (gsi, type);
1544 else if (is_gimple_assign (stmt)
1545 && (gimple_assign_rhs_code (stmt) == REALPART_EXPR
1546 || gimple_assign_rhs_code (stmt) == IMAGPART_EXPR)
1547 && TREE_CODE (lhs) == SSA_NAME)
1549 rhs = gimple_assign_rhs1 (stmt);
1550 rhs = extract_component (gsi, TREE_OPERAND (rhs, 0),
1551 gimple_assign_rhs_code (stmt)
1554 gimple_assign_set_rhs_from_tree (gsi, rhs);
1555 stmt = gsi_stmt (*gsi);
1562 /* Extract the components of the two complex values. Make sure and
1563 handle the common case of the same value used twice specially. */
1564 if (is_gimple_assign (stmt))
1566 ac = gimple_assign_rhs1 (stmt);
1567 bc = (gimple_num_ops (stmt) > 2) ? gimple_assign_rhs2 (stmt) : NULL;
1569 /* GIMPLE_CALL can not get here. */
1572 ac = gimple_cond_lhs (stmt);
1573 bc = gimple_cond_rhs (stmt);
1576 ar = extract_component (gsi, ac, false, true);
1577 ai = extract_component (gsi, ac, true, true);
1583 br = extract_component (gsi, bc, 0, true);
1584 bi = extract_component (gsi, bc, 1, true);
1587 br = bi = NULL_TREE;
1589 if (gimple_in_ssa_p (cfun))
1591 al = find_lattice_value (ac);
1592 if (al == UNINITIALIZED)
1595 if (TREE_CODE_CLASS (code) == tcc_unary)
1601 bl = find_lattice_value (bc);
1602 if (bl == UNINITIALIZED)
1613 expand_complex_addition (gsi, inner_type, ar, ai, br, bi, code, al, bl);
1617 expand_complex_multiplication (gsi, inner_type, ar, ai, br, bi, al, bl);
1620 case TRUNC_DIV_EXPR:
1622 case FLOOR_DIV_EXPR:
1623 case ROUND_DIV_EXPR:
1625 expand_complex_division (gsi, inner_type, ar, ai, br, bi, code, al, bl);
1629 expand_complex_negation (gsi, inner_type, ar, ai);
1633 expand_complex_conjugate (gsi, inner_type, ar, ai);
1638 expand_complex_comparison (gsi, ar, ai, br, bi, code);
1647 /* Entry point for complex operation lowering during optimization. */
1650 tree_lower_complex (void)
1652 int old_last_basic_block;
1653 gimple_stmt_iterator gsi;
1656 if (!init_dont_simulate_again ())
1659 complex_lattice_values.create (num_ssa_names);
1660 complex_lattice_values.safe_grow_cleared (num_ssa_names);
1662 init_parameter_lattice_values ();
1663 ssa_propagate (complex_visit_stmt, complex_visit_phi);
1665 complex_variable_components = new int_tree_htab_type (10);
1667 complex_ssa_name_components.create (2 * num_ssa_names);
1668 complex_ssa_name_components.safe_grow_cleared (2 * num_ssa_names);
1670 update_parameter_components ();
1672 /* ??? Ideally we'd traverse the blocks in breadth-first order. */
1673 old_last_basic_block = last_basic_block_for_fn (cfun);
1674 FOR_EACH_BB_FN (bb, cfun)
1676 if (bb->index >= old_last_basic_block)
1679 update_phi_components (bb);
1680 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
1681 expand_complex_operations_1 (&gsi);
1684 gsi_commit_edge_inserts ();
1686 delete complex_variable_components;
1687 complex_variable_components = NULL;
1688 complex_ssa_name_components.release ();
1689 complex_lattice_values.release ();
1695 const pass_data pass_data_lower_complex =
1697 GIMPLE_PASS, /* type */
1698 "cplxlower", /* name */
1699 OPTGROUP_NONE, /* optinfo_flags */
1700 TV_NONE, /* tv_id */
1701 PROP_ssa, /* properties_required */
1702 PROP_gimple_lcx, /* properties_provided */
1703 0, /* properties_destroyed */
1704 0, /* todo_flags_start */
1705 TODO_update_ssa, /* todo_flags_finish */
1708 class pass_lower_complex : public gimple_opt_pass
1711 pass_lower_complex (gcc::context *ctxt)
1712 : gimple_opt_pass (pass_data_lower_complex, ctxt)
1715 /* opt_pass methods: */
1716 opt_pass * clone () { return new pass_lower_complex (m_ctxt); }
1717 virtual unsigned int execute (function *) { return tree_lower_complex (); }
1719 }; // class pass_lower_complex
1724 make_pass_lower_complex (gcc::context *ctxt)
1726 return new pass_lower_complex (ctxt);
1732 const pass_data pass_data_lower_complex_O0 =
1734 GIMPLE_PASS, /* type */
1735 "cplxlower0", /* name */
1736 OPTGROUP_NONE, /* optinfo_flags */
1737 TV_NONE, /* tv_id */
1738 PROP_cfg, /* properties_required */
1739 PROP_gimple_lcx, /* properties_provided */
1740 0, /* properties_destroyed */
1741 0, /* todo_flags_start */
1742 TODO_update_ssa, /* todo_flags_finish */
1745 class pass_lower_complex_O0 : public gimple_opt_pass
1748 pass_lower_complex_O0 (gcc::context *ctxt)
1749 : gimple_opt_pass (pass_data_lower_complex_O0, ctxt)
1752 /* opt_pass methods: */
1753 virtual bool gate (function *fun)
1755 /* With errors, normal optimization passes are not run. If we don't
1756 lower complex operations at all, rtl expansion will abort. */
1757 return !(fun->curr_properties & PROP_gimple_lcx);
1760 virtual unsigned int execute (function *) { return tree_lower_complex (); }
1762 }; // class pass_lower_complex_O0
1767 make_pass_lower_complex_O0 (gcc::context *ctxt)
1769 return new pass_lower_complex_O0 (ctxt);