- int unsignedp0;
- enum rtx_code rcode0;
-
- unsignedp0 = TYPE_UNSIGNED (TREE_TYPE (gimple_assign_rhs1 (gs0)));
- rcode0 = get_rtx_code (code0, unsignedp0);
-
- tmp = targetm.gen_ccmp_first (prep_seq, gen_seq, rcode0,
- gimple_assign_rhs1 (gs0),
- gimple_assign_rhs2 (gs0));
- if (!tmp)
+ int unsignedp0, unsignedp1;
+ rtx_code rcode0, rcode1;
+ tree logical_op0_rhs1, logical_op0_rhs2;
+ tree logical_op1_rhs1, logical_op1_rhs2;
+ int speed_p = optimize_insn_for_speed_p ();
+
+ rtx tmp2 = NULL_RTX, ret = NULL_RTX, ret2 = NULL_RTX;
+ unsigned cost1 = MAX_COST;
+ unsigned cost2 = MAX_COST;
+
+ get_compare_parts (op0, &unsignedp0, &rcode0,
+ &logical_op0_rhs1, &logical_op0_rhs2);
+
+ get_compare_parts (op1, &unsignedp1, &rcode1,
+ &logical_op1_rhs1, &logical_op1_rhs2);
+
+ rtx_insn *prep_seq_1, *gen_seq_1;
+ tmp = targetm.gen_ccmp_first (&prep_seq_1, &gen_seq_1, rcode0,
+ logical_op0_rhs1, logical_op0_rhs2);
+ if (tmp != NULL)
+ {
+ ret = expand_ccmp_next (op1, code, tmp, &prep_seq_1, &gen_seq_1);
+ cost1 = seq_cost (prep_seq_1, speed_p);
+ cost1 += seq_cost (gen_seq_1, speed_p);
+ }
+
+ /* FIXME: Temporary workaround for PR69619.
+ Avoid exponential compile time due to expanding gs0 and gs1 twice.
+ If gs0 and gs1 are complex, the cost will be high, so avoid
+ reevaluation if above an arbitrary threshold. */
+ rtx_insn *prep_seq_2, *gen_seq_2;
+ if (tmp == NULL || cost1 < COSTS_N_INSNS (25))
+ tmp2 = targetm.gen_ccmp_first (&prep_seq_2, &gen_seq_2, rcode1,
+ logical_op1_rhs1, logical_op1_rhs2);
+ if (!tmp && !tmp2)