Lines Matching refs:op2
38 …p_fold(ir_ctx *ctx, ir_insn *_values, ir_ref res, uint32_t opt, ir_ref op1, ir_ref op2, ir_ref op3) in ir_sccp_fold() argument
44 op2 = ir_sccp_identity(_values, op2); in ir_sccp_fold()
50 op2_insn = (op2 > 0 && IR_IS_CONST_OP(_values[op2].op)) ? _values + op2 : ctx->ir_base + op2; in ir_sccp_fold()
53 switch (ir_folding(ctx, opt, op1, op2, op3, op1_insn, op2_insn, op3_insn)) { in ir_sccp_fold()
57 op2 = ctx->fold_insn.op2; in ir_sccp_fold()
500 ir_ref op1, op2, op3; in ir_sccp_fold2() local
506 op2 = insn->op2; in ir_sccp_fold2()
511 op2_insn = ctx->ir_base + op2; in ir_sccp_fold2()
514 switch (ir_folding(ctx, opt, op1, op2, op3, op1_insn, op2_insn, op3_insn)) { in ir_sccp_fold2()
518 op2 = ctx->fold_insn.op2; in ir_sccp_fold2()
525 || insn->op2 != ctx->fold_insn.op2 in ir_sccp_fold2()
542 if (insn->op2 != ctx->fold_insn.op2) { in ir_sccp_fold2()
543 if (insn->op2 > 0) { in ir_sccp_fold2()
544 ir_use_list_remove_one(ctx, insn->op2, ref); in ir_sccp_fold2()
546 if (ctx->fold_insn.op2 > 0) { in ir_sccp_fold2()
547 ir_use_list_add(ctx, ctx->fold_insn.op2, ref); in ir_sccp_fold2()
559 insn->op2 = ctx->fold_insn.op2; in ir_sccp_fold2()
600 insn->op2 = IR_UNUSED; in ir_sccp_remove_if()
759 ir_may_promote_d2f(ctx, insn->op2); in ir_may_promote_d2f()
792 ir_may_promote_f2d(ctx, insn->op2); in ir_may_promote_f2d()
847 if (insn->op1 == insn->op2) { in ir_promote_d2f()
848 insn->op2 = insn->op1 = ir_promote_d2f(ctx, insn->op1, ref); in ir_promote_d2f()
851 insn->op2 = ir_promote_d2f(ctx, insn->op2, ref); in ir_promote_d2f()
920 if (insn->op1 == insn->op2) { in ir_promote_f2d()
921 insn->op2 = insn->op1 = ir_promote_f2d(ctx, insn->op1, ref); in ir_promote_f2d()
924 insn->op2 = ir_promote_f2d(ctx, insn->op2, ref); in ir_promote_f2d()
963 ir_may_promote_i2i(ctx, type, insn->op2); in ir_may_promote_i2i()
1019 if (insn->op1 == insn->op2) { in ir_promote_i2i()
1020 insn->op2 = insn->op1 = ir_promote_i2i(ctx, type, insn->op1, ref); in ir_promote_i2i()
1023 insn->op2 = ir_promote_i2i(ctx, type, insn->op2, ref); in ir_promote_i2i()
1121 || (op_insn->op1 != ref && op_insn->op2 != ref) in ir_try_promote_ext()
1137 && (use_insn->op1 == ref || use_insn->op2 == ref)) { in ir_try_promote_ext()
1163 && (use_insn->op1 == ref || use_insn->op2 == ref)); in ir_try_promote_ext()
1172 if (use_insn->op2 != ref) { in ir_try_promote_ext()
1173 if (IR_IS_CONST_REF(use_insn->op2) in ir_try_promote_ext()
1174 && !IR_IS_SYM_CONST(ctx->ir_base[use_insn->op2].op)) { in ir_try_promote_ext()
1175 ctx->ir_base[use].op2 = ir_ext_const(ctx, &ctx->ir_base[use_insn->op2], op, type); in ir_try_promote_ext()
1177 ctx->ir_base[use].op2 = ir_ext_ref(ctx, use, use_insn->op2, op, type, worklist); in ir_try_promote_ext()
1186 if (IR_IS_CONST_REF(phi_insn->op2) in ir_try_promote_ext()
1187 && !IR_IS_SYM_CONST(ctx->ir_base[phi_insn->op2].op)) { in ir_try_promote_ext()
1188 ctx->ir_base[ref].op2 = ir_ext_const(ctx, &ctx->ir_base[phi_insn->op2], op, type); in ir_try_promote_ext()
1190 ctx->ir_base[ref].op2 = ir_ext_ref(ctx, ref, phi_insn->op2, op, type, worklist); in ir_try_promote_ext()
1246 ir_ref end1_ref = insn->op1, end2_ref = insn->op2; in ir_try_remove_empty_diamond()
1297 if (!IR_IS_CONST_REF(root->op2)) { in ir_try_remove_empty_diamond()
1298 ir_use_list_remove_all(ctx, root->op2, root_ref); in ir_try_remove_empty_diamond()
1299 if (ir_is_dead(ctx, root->op2)) { in ir_try_remove_empty_diamond()
1300 ir_bitqueue_add(worklist, root->op2); in ir_try_remove_empty_diamond()
1353 if (!IR_IS_CONST_REF(root->op2)) { in ir_try_remove_empty_diamond()
1354 ir_use_list_remove_all(ctx, root->op2, root_ref); in ir_try_remove_empty_diamond()
1355 if (ir_is_dead(ctx, root->op2)) { in ir_try_remove_empty_diamond()
1356 ir_bitqueue_add(worklist, root->op2); in ir_try_remove_empty_diamond()
1394 ir_ref end1_ref = merge->op1, end2_ref = merge->op2; in ir_optimize_phi()
1407 if (root->op == IR_IF && ctx->use_lists[root->op2].count == 1) { in ir_optimize_phi()
1408 ir_ref cond_ref = root->op2; in ir_optimize_phi()
1428 && ((insn->op2 == cond->op1 && insn->op3 == cond->op2) in ir_optimize_phi()
1429 || (insn->op2 == cond->op2 && insn->op3 == cond->op1))) { in ir_optimize_phi()
1461 (is_less ? cond->op1 : cond->op2) in ir_optimize_phi()
1463 ((start1->op == IR_IF_TRUE) ? insn->op2 : insn->op3) in ir_optimize_phi()
1466 if (insn->op2 > insn->op3) { in ir_optimize_phi()
1467 insn->op1 = insn->op2; in ir_optimize_phi()
1468 insn->op2 = insn->op3; in ir_optimize_phi()
1479 if (!IR_IS_CONST_REF(insn->op2)) { in ir_optimize_phi()
1480 ir_use_list_remove_all(ctx, insn->op2, cond_ref); in ir_optimize_phi()
1497 && ((ctx->ir_base[insn->op2].op == IR_NEG in ir_optimize_phi()
1498 && ctx->use_lists[insn->op2].count == 1 in ir_optimize_phi()
1499 && ctx->ir_base[insn->op2].op1 == insn->op3 in ir_optimize_phi()
1501 && ir_is_zero(ctx, cond->op2) in ir_optimize_phi()
1503 || (cond->op2 == insn->op3 in ir_optimize_phi()
1508 && ctx->ir_base[insn->op3].op1 == insn->op2 in ir_optimize_phi()
1509 && ((cond->op1 == insn->op2 in ir_optimize_phi()
1510 && ir_is_zero(ctx, cond->op2) in ir_optimize_phi()
1512 || (cond->op2 == insn->op2 in ir_optimize_phi()
1548 if (ctx->ir_base[insn->op2].op == IR_NEG) { in ir_optimize_phi()
1549 neg_ref = insn->op2; in ir_optimize_phi()
1553 insn->op1 = insn->op2; in ir_optimize_phi()
1555 insn->op2 = IR_UNUSED; in ir_optimize_phi()
1615 SWAP_REFS(insn->op2, insn->op3); in ir_optimize_phi()
1621 ir_use_list_remove_all(ctx, root->op2, root_ref); in ir_optimize_phi()
1644 static bool ir_cmp_is_true(ir_op op, ir_insn *op1, ir_insn *op2) in ir_cmp_is_true() argument
1646 IR_ASSERT(op1->type == op2->type); in ir_cmp_is_true()
1649 return op1->val.u64 == op2->val.u64; in ir_cmp_is_true()
1651 return op1->val.u64 != op2->val.u64; in ir_cmp_is_true()
1654 return op1->val.i64 < op2->val.i64; in ir_cmp_is_true()
1656 return op1->val.u64 < op2->val.u64; in ir_cmp_is_true()
1660 return op1->val.i64 >= op2->val.i64; in ir_cmp_is_true()
1662 return op1->val.u64 >= op2->val.u64; in ir_cmp_is_true()
1666 return op1->val.i64 <= op2->val.i64; in ir_cmp_is_true()
1668 return op1->val.u64 <= op2->val.u64; in ir_cmp_is_true()
1672 return op1->val.i64 > op2->val.i64; in ir_cmp_is_true()
1674 return op1->val.u64 > op2->val.u64; in ir_cmp_is_true()
1677 return op1->val.u64 < op2->val.u64; in ir_cmp_is_true()
1679 return op1->val.u64 >= op2->val.u64; in ir_cmp_is_true()
1681 return op1->val.u64 <= op2->val.u64; in ir_cmp_is_true()
1683 return op1->val.u64 > op2->val.u64; in ir_cmp_is_true()
1690 return op1->val.d == op2->val.d; in ir_cmp_is_true()
1692 return op1->val.d != op2->val.d; in ir_cmp_is_true()
1694 return op1->val.d < op2->val.d; in ir_cmp_is_true()
1696 return op1->val.d >= op2->val.d; in ir_cmp_is_true()
1698 return op1->val.d <= op2->val.d; in ir_cmp_is_true()
1700 return op1->val.d > op2->val.d; in ir_cmp_is_true()
1702 return !(op1->val.d >= op2->val.d); in ir_cmp_is_true()
1704 return !(op1->val.d < op2->val.d); in ir_cmp_is_true()
1706 return !(op1->val.d > op2->val.d); in ir_cmp_is_true()
1708 return !(op1->val.d <= op2->val.d); in ir_cmp_is_true()
1716 return op1->val.f == op2->val.f; in ir_cmp_is_true()
1718 return op1->val.f != op2->val.f; in ir_cmp_is_true()
1720 return op1->val.f < op2->val.f; in ir_cmp_is_true()
1722 return op1->val.f >= op2->val.f; in ir_cmp_is_true()
1724 return op1->val.f <= op2->val.f; in ir_cmp_is_true()
1726 return op1->val.f > op2->val.f; in ir_cmp_is_true()
1728 return !(op1->val.f >= op2->val.f); in ir_cmp_is_true()
1730 return !(op1->val.f < op2->val.f); in ir_cmp_is_true()
1732 return !(op1->val.f > op2->val.f); in ir_cmp_is_true()
1734 return !(op1->val.f <= op2->val.f); in ir_cmp_is_true()
1744 ir_ref cond_ref = insn->op2; in ir_try_split_if()
1750 && ((IR_IS_CONST_REF(cond->op2) && !IR_IS_SYM_CONST(ctx->ir_base[cond->op2].op)) in ir_try_split_if()
1756 ir_ref end1_ref = merge->op1, end2_ref = merge->op2; in ir_try_split_if()
1767 if (!IR_IS_CONST_REF(cond->op2) || IR_IS_SYM_CONST(ctx->ir_base[cond->op2].op)) { in ir_try_split_if()
1769 SWAP_REFS(cond->op2, cond->op3); in ir_try_split_if()
1770 SWAP_REFS(merge->op1, merge->op2); in ir_try_split_if()
1774 if (ir_const_is_true(&ctx->ir_base[cond->op2])) { in ir_try_split_if()
1846 if_false->op2 = end2_ref; in ir_try_split_if()
1886 end2->op2 = cond->op3; in ir_try_split_if()
1890 merge->op2 = IR_UNUSED; in ir_try_split_if()
1897 insn->op2 = IR_UNUSED; in ir_try_split_if()
1903 if_false->op2 = ref; in ir_try_split_if()
1920 ir_ref cond_ref = insn->op2; in ir_try_split_if_cmp()
1924 && IR_IS_CONST_REF(cond->op2) in ir_try_split_if_cmp()
1925 && !IR_IS_SYM_CONST(ctx->ir_base[cond->op2].op) in ir_try_split_if_cmp()
1926 && ctx->use_lists[insn->op2].count == 1) { in ir_try_split_if_cmp()
1934 && ((IR_IS_CONST_REF(phi->op2) && !IR_IS_SYM_CONST(ctx->ir_base[phi->op2].op)) in ir_try_split_if_cmp()
1940 ir_ref end1_ref = merge->op1, end2_ref = merge->op2; in ir_try_split_if_cmp()
1951 if (!IR_IS_CONST_REF(phi->op2) || IR_IS_SYM_CONST(ctx->ir_base[phi->op2].op)) { in ir_try_split_if_cmp()
1953 SWAP_REFS(phi->op2, phi->op3); in ir_try_split_if_cmp()
1954 SWAP_REFS(merge->op1, merge->op2); in ir_try_split_if_cmp()
1958 if (ir_cmp_is_true(cond->op, &ctx->ir_base[phi->op2], &ctx->ir_base[cond->op2])) { in ir_try_split_if_cmp()
1966 …if (ir_cmp_is_true(cond->op, &ctx->ir_base[phi->op3], &ctx->ir_base[cond->op2]) ^ (op == IR_IF_TRU… in ir_try_split_if_cmp()
2038 if_false->op2 = end2_ref; in ir_try_split_if_cmp()
2074 ir_use_list_replace_one(ctx, phi->op3, phi_ref, insn->op2); in ir_try_split_if_cmp()
2081 end2->op2 = insn->op2; in ir_try_split_if_cmp()
2085 merge->op2 = IR_UNUSED; in ir_try_split_if_cmp()
2093 insn->op2 = IR_UNUSED; in ir_try_split_if_cmp()
2099 if_false->op2 = ref; in ir_try_split_if_cmp()
2133 if (next->op2 == phi_ref) { in ir_optimize_merge()
2138 ir_insn *cmp = &ctx->ir_base[next->op2]; in ir_optimize_merge()
2142 && IR_IS_CONST_REF(cmp->op2) in ir_optimize_merge()
2143 && !IR_IS_SYM_CONST(ctx->ir_base[cmp->op2].op) in ir_optimize_merge()
2144 && ctx->use_lists[next->op2].count == 1) { in ir_optimize_merge()
2219 } else if (!ir_sccp_fold(ctx, _values, i, insn->opt, insn->op1, insn->op2, insn->op3)) { in ir_sccp()
2271 if (IR_IS_TOP(insn->op2)) { in ir_sccp()
2273 if (!_values[insn->op2].op1) { in ir_sccp()
2274 _values[insn->op2].op1 = 1; in ir_sccp()
2275 ir_bitqueue_add(&worklist, insn->op2); in ir_sccp()
2279 if (!IR_IS_BOTTOM(insn->op2) in ir_sccp()
2281 && (IR_IS_CONST_REF(insn->op2) || _values[insn->op2].op != IR_COPY) in ir_sccp()
2284 bool b = ir_sccp_is_true(ctx, _values, insn->op2); in ir_sccp()
2308 if (IR_IS_TOP(insn->op2)) { in ir_sccp()
2310 if (!_values[insn->op2].op1) { in ir_sccp()
2311 _values[insn->op2].op1 = 1; in ir_sccp()
2312 ir_bitqueue_add(&worklist, insn->op2); in ir_sccp()
2316 if (!IR_IS_BOTTOM(insn->op2) in ir_sccp()
2318 && (IR_IS_CONST_REF(insn->op2) || _values[insn->op2].op != IR_COPY) in ir_sccp()
2330 if (ir_sccp_is_equal(ctx, _values, insn->op2, use_insn->op2)) { in ir_sccp()
2376 use = insn->op2; in ir_sccp()