-
- pn = get_Proj_proj(sel);
- cl = get_Cmp_left(cmp);
- cr = get_Cmp_right(cmp);
-
- if (ia32_cg_config.use_cmov) {
- if (ia32_cg_config.use_sse2) {
- /* check the Phi nodes: no 64bit and no floating point cmov */
- for (phi = phi_list; phi; phi = get_Phi_next(phi)) {
- ir_mode *mode = get_irn_mode(phi);
-
- if (mode_is_float(mode)) {
- /* check for Min, Max */
- ir_node *t = get_Phi_pred(phi, i);
- ir_node *f = get_Phi_pred(phi, j);
-
- /* SSE2 supports Min & Max */
- if (pn == pn_Cmp_Lt || pn == pn_Cmp_Le || pn == pn_Cmp_Ge || pn == pn_Cmp_Gt) {
- if (cl == t && cr == f) {
- /* Mux(a <=/>= b, a, b) => MIN, MAX */
- continue;
- } else if (cl == f && cr == t) {
- /* Mux(a <=/>= b, b, a) => MAX, MIN */
- continue;
- }
- }
- return 0;
- } else if (get_mode_size_bits(mode) > 32) {
- /* no 64bit cmov */
- return 0;
- }
- }
- } else {
- /* check the Phi nodes: no 64bit and no floating point cmov */
- for (phi = phi_list; phi; phi = get_Phi_next(phi)) {
- ir_mode *mode = get_irn_mode(phi);
-
- if (mode_is_float(mode)) {
- ir_node *t = get_Phi_pred(phi, i);
- ir_node *f = get_Phi_pred(phi, j);
-
- /* always support Mux(!float, C1, C2) */
- if (is_Const(t) && is_Const(f) && !mode_is_float(get_irn_mode(cl))) {
- switch (be_transformer) {
- case TRANSFORMER_DEFAULT:
- /* always support Mux(!float, C1, C2) */
- continue;
+ if (!is_Const(mux_false) || !is_Const_null(mux_false))
+ return false;
+ if (!is_Sub(mux_true))
+ return false;
+ sub_left = get_Sub_left(mux_true);
+ sub_right = get_Sub_right(mux_true);
+
+ /* Mux(a >=u b, 0, a-b) */
+ if ((pn == pn_Cmp_Gt || pn == pn_Cmp_Ge)
+ && sub_left == cmp_left && sub_right == cmp_right)
+ return true;
+ /* Mux(a <=u b, 0, b-a) */
+ if ((pn == pn_Cmp_Lt || pn == pn_Cmp_Le)
+ && sub_left == cmp_right && sub_right == cmp_left)
+ return true;
+
+ return false;
+}
+
+static int ia32_is_mux_allowed(ir_node *sel, ir_node *mux_false,
+ ir_node *mux_true)
+{
+ ir_mode *mode;
+
+ /* we can handle Set for all modes and compares */
+ if (mux_is_set(sel, mux_true, mux_false))
+ return true;
+ /* SSE has own min/max operations */
+ if (ia32_cg_config.use_sse2
+ && mux_is_float_min_max(sel, mux_true, mux_false))
+ return true;
+ /* we can handle Mux(?, Const[f], Const[f]) */
+ if (mux_is_float_const_const(sel, mux_true, mux_false)) {