Lines Matching refs:insn

40 	ir_insn *op1_insn, *op2_insn, *op3_insn, *insn;  in ir_sccp_fold()  local
68 insn = (op1 > 0 && IR_IS_CONST_OP(_values[op1].op)) ? _values + op1 : ctx->ir_base + op1; in ir_sccp_fold()
69 if (IR_IS_CONST_OP(insn->op)) { in ir_sccp_fold()
73 _values[res].optx = IR_OPT(IR_COPY, insn->type); in ir_sccp_fold()
81 _values[res].optx = IR_OPT(IR_COPY, insn->type); in ir_sccp_fold()
92 insn = &ctx->fold_insn; in ir_sccp_fold()
100 _values[res].optx = IR_OPT(insn->type, insn->type); in ir_sccp_fold()
101 _values[res].val.u64 = insn->val.u64; in ir_sccp_fold()
103 …} else if (_values[res].opt != IR_OPT(insn->type, insn->type) || _values[res].val.u64 != insn->val… in ir_sccp_fold()
110 static bool ir_sccp_meet_phi(ir_ctx *ctx, ir_insn *_values, ir_ref i, ir_insn *insn, ir_bitqueue *w… in ir_sccp_meet_phi() argument
118 if (!IR_IS_FEASIBLE(insn->op1)) { in ir_sccp_meet_phi()
121 n = insn->inputs_count; in ir_sccp_meet_phi()
128 p = insn->ops + 2; in ir_sccp_meet_phi()
129 merge_input = ctx->ir_base[insn->op1].ops + 1; in ir_sccp_meet_phi()
254 static bool ir_is_dead_load_ex(ir_ctx *ctx, ir_ref ref, uint32_t flags, ir_insn *insn) in ir_is_dead_load_ex() argument
258 } else if (insn->op == IR_ALLOCA) { in ir_is_dead_load_ex()
327 ir_insn *insn; in ir_sccp_make_nop() local
330 insn = &ctx->ir_base[ref]; in ir_sccp_make_nop()
331 n = insn->inputs_count; in ir_sccp_make_nop()
332 insn->opt = IR_NOP; /* keep "inputs_count" */ in ir_sccp_make_nop()
333 for (j = 1, p = insn->ops + j; j <= n; j++, p++) { in ir_sccp_make_nop()
341 ir_insn *insn; in ir_sccp_remove_insn() local
344 insn = &ctx->ir_base[ref]; in ir_sccp_remove_insn()
345 n = insn->inputs_count; in ir_sccp_remove_insn()
346 insn->opt = IR_NOP; /* keep "inputs_count" */ in ir_sccp_remove_insn()
347 for (j = 1, p = insn->ops + j; j <= n; j++, p++) { in ir_sccp_remove_insn()
364 ir_insn *insn; in ir_sccp_remove_insn2() local
367 insn = &ctx->ir_base[ref]; in ir_sccp_remove_insn2()
368 n = insn->inputs_count; in ir_sccp_remove_insn2()
369 insn->opt = IR_NOP; /* keep "inputs_count" */ in ir_sccp_remove_insn2()
370 for (j = 1, p = insn->ops + j; j <= n; j++, p++) { in ir_sccp_remove_insn2()
389 ir_insn *insn; in ir_sccp_replace_insn() local
394 insn = &ctx->ir_base[ref]; in ir_sccp_replace_insn()
395 n = insn->inputs_count; in ir_sccp_replace_insn()
396 insn->opt = IR_NOP; /* keep "inputs_count" */ in ir_sccp_replace_insn()
397 for (j = 1, p = insn->ops + 1; j <= n; j++, p++) { in ir_sccp_replace_insn()
415 insn = &ctx->ir_base[use]; in ir_sccp_replace_insn()
416 l = insn->inputs_count; in ir_sccp_replace_insn()
418 if (ir_insn_op(insn, k) == ref) { in ir_sccp_replace_insn()
419 ir_insn_set_op(insn, k, new_ref); in ir_sccp_replace_insn()
446 ir_insn *insn; in ir_sccp_replace_insn2() local
451 insn = &ctx->ir_base[ref]; in ir_sccp_replace_insn2()
452 n = insn->inputs_count; in ir_sccp_replace_insn2()
453 insn->opt = IR_NOP; /* keep "inputs_count" */ in ir_sccp_replace_insn2()
454 for (j = 1, p = insn->ops + 1; j <= n; j++, p++) { in ir_sccp_replace_insn2()
473 insn = &ctx->ir_base[use]; in ir_sccp_replace_insn2()
474 l = insn->inputs_count; in ir_sccp_replace_insn2()
476 if (ir_insn_op(insn, k) == ref) { in ir_sccp_replace_insn2()
477 ir_insn_set_op(insn, k, new_ref); in ir_sccp_replace_insn2()
501 ir_insn *op1_insn, *op2_insn, *op3_insn, *insn; in ir_sccp_fold2() local
503 insn = &ctx->ir_base[ref]; in ir_sccp_fold2()
504 opt = insn->opt; in ir_sccp_fold2()
505 op1 = insn->op1; in ir_sccp_fold2()
506 op2 = insn->op2; in ir_sccp_fold2()
507 op3 = insn->op3; in ir_sccp_fold2()
522 insn = &ctx->ir_base[ref]; in ir_sccp_fold2()
523 if (insn->opt != ctx->fold_insn.opt in ir_sccp_fold2()
524 || insn->op1 != ctx->fold_insn.op1 in ir_sccp_fold2()
525 || insn->op2 != ctx->fold_insn.op2 in ir_sccp_fold2()
526 || insn->op3 != ctx->fold_insn.op3) { in ir_sccp_fold2()
531 insn->optx = ctx->fold_insn.opt; in ir_sccp_fold2()
533 insn->inputs_count = IR_INPUT_EDGES_COUNT(ir_op_flags[opt & IR_OPT_OP_MASK]); in ir_sccp_fold2()
534 if (insn->op1 != ctx->fold_insn.op1) { in ir_sccp_fold2()
535 if (insn->op1 > 0) { in ir_sccp_fold2()
536 ir_use_list_remove_one(ctx, insn->op1, ref); 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()
550 if (insn->op3 != ctx->fold_insn.op3) { in ir_sccp_fold2()
551 if (insn->op3 > 0) { in ir_sccp_fold2()
552 ir_use_list_remove_one(ctx, insn->op3, ref); in ir_sccp_fold2()
558 insn->op1 = ctx->fold_insn.op1; in ir_sccp_fold2()
559 insn->op2 = ctx->fold_insn.op2; in ir_sccp_fold2()
560 insn->op3 = ctx->fold_insn.op3; in ir_sccp_fold2()
587 ir_insn *insn, *next_insn; in ir_sccp_remove_if() local
589 insn = &ctx->ir_base[ref]; in ir_sccp_remove_if()
594 next_insn->op1 = insn->op1; in ir_sccp_remove_if()
595 ir_use_list_replace_one(ctx, insn->op1, ref, next); in ir_sccp_remove_if()
600 insn->op2 = IR_UNUSED; in ir_sccp_remove_if()
601 insn->optx = IR_OPTX(IR_END, IR_VOID, 1); in ir_sccp_remove_if()
610 ir_insn *insn, *use_insn; in ir_sccp_remove_unfeasible_merge_inputs() local
614 insn = &ctx->ir_base[ref]; in ir_sccp_remove_unfeasible_merge_inputs()
615 IR_ASSERT(insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN); in ir_sccp_remove_unfeasible_merge_inputs()
616 n = insn->inputs_count; in ir_sccp_remove_unfeasible_merge_inputs()
620 ir_ref input = ir_insn_op(insn, j); in ir_sccp_remove_unfeasible_merge_inputs()
662 ir_insn_set_op(insn, i, IR_UNUSED); in ir_sccp_remove_unfeasible_merge_inputs()
664 insn->op = IR_BEGIN; in ir_sccp_remove_unfeasible_merge_inputs()
665 insn->op1 = input; in ir_sccp_remove_unfeasible_merge_inputs()
671 ir_insn_set_op(insn, i, IR_UNUSED); in ir_sccp_remove_unfeasible_merge_inputs()
673 insn->op = IR_BEGIN; in ir_sccp_remove_unfeasible_merge_inputs()
674 insn->op1 = input; in ir_sccp_remove_unfeasible_merge_inputs()
679 n = insn->inputs_count; in ir_sccp_remove_unfeasible_merge_inputs()
683 ir_ref input = ir_insn_op(insn, j); in ir_sccp_remove_unfeasible_merge_inputs()
687 ir_insn_set_op(insn, i, input); in ir_sccp_remove_unfeasible_merge_inputs()
695 ir_insn_set_op(insn, j, IR_UNUSED); in ir_sccp_remove_unfeasible_merge_inputs()
699 insn->inputs_count = i; in ir_sccp_remove_unfeasible_merge_inputs()
726 use_insn->inputs_count = insn->inputs_count + 1; in ir_sccp_remove_unfeasible_merge_inputs()
736 ir_insn *insn = &ctx->ir_base[ref]; in ir_may_promote_d2f() local
738 IR_ASSERT(insn->type == IR_DOUBLE); in ir_may_promote_d2f()
740 return !IR_IS_SYM_CONST(insn->op) && insn->val.d == (double)(float)insn->val.d; in ir_may_promote_d2f()
742 switch (insn->op) { in ir_may_promote_d2f()
750 ir_may_promote_d2f(ctx, insn->op1); in ir_may_promote_d2f()
758 ir_may_promote_d2f(ctx, insn->op1) && in ir_may_promote_d2f()
759 ir_may_promote_d2f(ctx, insn->op2); in ir_may_promote_d2f()
769 ir_insn *insn = &ctx->ir_base[ref]; in ir_may_promote_f2d() local
771 IR_ASSERT(insn->type == IR_FLOAT); in ir_may_promote_f2d()
773 return !IR_IS_SYM_CONST(insn->op) && insn->val.f == (float)(double)insn->val.f; in ir_may_promote_f2d()
775 switch (insn->op) { in ir_may_promote_f2d()
783 ir_may_promote_f2d(ctx, insn->op1); in ir_may_promote_f2d()
791 ir_may_promote_f2d(ctx, insn->op1) && in ir_may_promote_f2d()
792 ir_may_promote_f2d(ctx, insn->op2); in ir_may_promote_f2d()
802 ir_insn *insn = &ctx->ir_base[ref]; in ir_promote_d2f() local
805 IR_ASSERT(insn->type == IR_DOUBLE); in ir_promote_d2f()
807 return ir_const_float(ctx, (float)insn->val.d); in ir_promote_d2f()
809 switch (insn->op) { in ir_promote_d2f()
814 ir_use_list_replace_one(ctx, insn->op1, ref, use); in ir_promote_d2f()
817 ir_use_list_add(ctx, insn->op1, use); in ir_promote_d2f()
820 ref = insn->op1; in ir_promote_d2f()
821 MAKE_NOP(insn); in ir_promote_d2f()
824 ir_use_list_add(ctx, insn->op1, use); in ir_promote_d2f()
828 ir_use_list_add(ctx, insn->op1, use); in ir_promote_d2f()
832 return insn->op1; in ir_promote_d2f()
838 insn->op1 = ir_promote_d2f(ctx, insn->op1, ref); in ir_promote_d2f()
839 insn->type = IR_FLOAT; in ir_promote_d2f()
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()
850 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()
853 insn->type = IR_FLOAT; in ir_promote_d2f()
865 ir_insn *insn = &ctx->ir_base[ref]; in ir_promote_f2d() local
869 IR_ASSERT(insn->type == IR_FLOAT); in ir_promote_f2d()
871 return ir_const_double(ctx, (double)insn->val.f); in ir_promote_f2d()
873 switch (insn->op) { in ir_promote_f2d()
878 ir_use_list_replace_one(ctx, insn->op1, ref, use); in ir_promote_f2d()
881 ir_use_list_add(ctx, insn->op1, use); in ir_promote_f2d()
884 ref = insn->op1; in ir_promote_f2d()
885 MAKE_NOP(insn); in ir_promote_f2d()
888 ir_use_list_add(ctx, insn->op1, use); in ir_promote_f2d()
892 ir_use_list_add(ctx, insn->op1, use); in ir_promote_f2d()
896 return insn->op1; in ir_promote_f2d()
898 old_ref = ir_find1(ctx, IR_OPTX(IR_INT2FP, IR_DOUBLE, 1), insn->op1); in ir_promote_f2d()
901 ir_use_list_remove_one(ctx, insn->op1, ref); in ir_promote_f2d()
903 MAKE_NOP(insn); in ir_promote_f2d()
907 insn->type = IR_DOUBLE; in ir_promote_f2d()
911 insn->op1 = ir_promote_f2d(ctx, insn->op1, ref); in ir_promote_f2d()
912 insn->type = IR_DOUBLE; in ir_promote_f2d()
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()
923 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()
926 insn->type = IR_DOUBLE; in ir_promote_f2d()
938 ir_insn *insn = &ctx->ir_base[ref]; in ir_may_promote_i2i() local
941 return !IR_IS_SYM_CONST(insn->op); in ir_may_promote_i2i()
943 switch (insn->op) { in ir_may_promote_i2i()
946 return ctx->ir_base[insn->op1].type == type; in ir_may_promote_i2i()
951 ir_may_promote_i2i(ctx, type, insn->op1); in ir_may_promote_i2i()
962 ir_may_promote_i2i(ctx, type, insn->op1) && in ir_may_promote_i2i()
963 ir_may_promote_i2i(ctx, type, insn->op2); in ir_may_promote_i2i()
973 ir_insn *insn = &ctx->ir_base[ref]; in ir_promote_i2i() local
977 return ir_const(ctx, insn->val, type); in ir_promote_i2i()
979 switch (insn->op) { in ir_promote_i2i()
985 ir_use_list_replace_one(ctx, insn->op1, ref, use); in ir_promote_i2i()
988 ir_use_list_add(ctx, insn->op1, use); in ir_promote_i2i()
991 ref = insn->op1; in ir_promote_i2i()
992 MAKE_NOP(insn); in ir_promote_i2i()
995 ir_use_list_add(ctx, insn->op1, use); in ir_promote_i2i()
999 ir_use_list_add(ctx, insn->op1, use); in ir_promote_i2i()
1003 return insn->op1; in ir_promote_i2i()
1007 insn->op1 = ir_promote_i2i(ctx, type, insn->op1, ref); in ir_promote_i2i()
1008 insn->type = type; in ir_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()
1022 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()
1025 insn->type = type; in ir_promote_i2i()
1101 static bool ir_try_promote_ext(ir_ctx *ctx, ir_ref ext_ref, ir_insn *insn, ir_bitqueue *worklist) in ir_try_promote_ext() argument
1103 ir_type type = insn->type; in ir_try_promote_ext()
1104 ir_op op = insn->op; in ir_try_promote_ext()
1105 ir_ref ref = insn->op1; in ir_try_promote_ext()
1147 phi_insn->type = insn->type; in ir_try_promote_ext()
1148 op_insn->type = insn->type; in ir_try_promote_ext()
1243 static bool ir_try_remove_empty_diamond(ir_ctx *ctx, ir_ref ref, ir_insn *insn, ir_bitqueue *workli… in ir_try_remove_empty_diamond() argument
1245 if (insn->inputs_count == 2) { in ir_try_remove_empty_diamond()
1246 ir_ref end1_ref = insn->op1, end2_ref = insn->op2; in ir_try_remove_empty_diamond()
1309 MAKE_NOP(insn); CLEAR_USES(ref); in ir_try_remove_empty_diamond()
1317 ir_ref i, count = insn->inputs_count, *ops = insn->ops + 1; in ir_try_remove_empty_diamond()
1372 MAKE_NOP(insn); CLEAR_USES(ref); in ir_try_remove_empty_diamond()
1389 …e_phi(ir_ctx *ctx, ir_ref merge_ref, ir_insn *merge, ir_ref ref, ir_insn *insn, ir_bitqueue *workl… in ir_optimize_phi() argument
1391 IR_ASSERT(insn->inputs_count == 3); in ir_optimize_phi()
1410 ir_type type = insn->type; 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()
1460 insn->op = ( in ir_optimize_phi()
1463 ((start1->op == IR_IF_TRUE) ? insn->op2 : insn->op3) in ir_optimize_phi()
1465 insn->inputs_count = 2; 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()
1470 insn->op1 = insn->op3; in ir_optimize_phi()
1472 insn->op3 = IR_UNUSED; in ir_optimize_phi()
1476 if (!IR_IS_CONST_REF(insn->op1)) { in ir_optimize_phi()
1477 ir_use_list_remove_all(ctx, insn->op1, cond_ref); 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()
1500 && ((cond->op1 == insn->op3 in ir_optimize_phi()
1503 || (cond->op2 == insn->op3 in ir_optimize_phi()
1506 || (ctx->ir_base[insn->op3].op == IR_NEG in ir_optimize_phi()
1507 && ctx->use_lists[insn->op3].count == 1 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()
1512 || (cond->op2 == insn->op2 in ir_optimize_phi()
1546 insn->op = IR_ABS; in ir_optimize_phi()
1547 insn->inputs_count = 1; 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()
1550 insn->op1 = insn->op3; in ir_optimize_phi()
1552 neg_ref = insn->op3; in ir_optimize_phi()
1553 insn->op1 = insn->op2; in ir_optimize_phi()
1555 insn->op2 = IR_UNUSED; in ir_optimize_phi()
1556 insn->op3 = IR_UNUSED; in ir_optimize_phi()
1560 ir_use_list_remove_one(ctx, insn->op1, neg_ref); in ir_optimize_phi()
1561 if (!IR_IS_CONST_REF(insn->op1)) { in ir_optimize_phi()
1562 ir_use_list_remove_all(ctx, insn->op1, cond_ref); in ir_optimize_phi()
1611 insn->op = IR_COND; in ir_optimize_phi()
1612 insn->inputs_count = 3; in ir_optimize_phi()
1613 insn->op1 = cond_ref; in ir_optimize_phi()
1615 SWAP_REFS(insn->op2, insn->op3); in ir_optimize_phi()
1742 static bool ir_try_split_if(ir_ctx *ctx, ir_ref ref, ir_insn *insn, ir_bitqueue *worklist) in ir_try_split_if() argument
1744 ir_ref cond_ref = insn->op2; in ir_try_split_if()
1749 && cond->op1 == insn->op1 in ir_try_split_if()
1752 ir_ref merge_ref = insn->op1; in ir_try_split_if()
1806 MAKE_NOP(insn); CLEAR_USES(ref); in ir_try_split_if()
1842 MAKE_NOP(insn); CLEAR_USES(ref); in ir_try_split_if()
1895 insn->optx = IR_OPTX(IR_END, IR_VOID, 1); in ir_try_split_if()
1896 insn->op1 = merge_ref; in ir_try_split_if()
1897 insn->op2 = IR_UNUSED; in ir_try_split_if()
1918 static bool ir_try_split_if_cmp(ir_ctx *ctx, ir_ref ref, ir_insn *insn, ir_bitqueue *worklist) in ir_try_split_if_cmp() argument
1920 ir_ref cond_ref = insn->op2; in ir_try_split_if_cmp()
1926 && ctx->use_lists[insn->op2].count == 1) { in ir_try_split_if_cmp()
1932 && phi->op1 == insn->op1 in ir_try_split_if_cmp()
1936 ir_ref merge_ref = insn->op1; in ir_try_split_if_cmp()
1994 MAKE_NOP(insn); CLEAR_USES(ref); in ir_try_split_if_cmp()
2034 MAKE_NOP(insn); CLEAR_USES(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()
2091 insn->optx = IR_OPTX(IR_END, IR_VOID, 1); in ir_try_split_if_cmp()
2092 insn->op1 = merge_ref; in ir_try_split_if_cmp()
2093 insn->op2 = IR_UNUSED; in ir_try_split_if_cmp()
2161 ir_insn *insn, *use_insn, *value; in ir_sccp() local
2174 insn = &ctx->ir_base[i]; in ir_sccp()
2175 flags = ir_op_flags[insn->op]; in ir_sccp()
2180 } else if (insn->op == IR_PHI) { in ir_sccp()
2181 if (!ir_sccp_meet_phi(ctx, _values, i, insn, &worklist)) { in ir_sccp()
2184 } else if (EXPECTED(IR_IS_FOLDABLE_OP(insn->op))) { in ir_sccp()
2190 for (p = insn->ops + 1; n > 0; p++, n--) { in ir_sccp()
2215 if (insn->op == IR_FP2FP || insn->op == IR_FP2INT || insn->op == IR_TRUNC in ir_sccp()
2216 || insn->op == IR_ZEXT || insn->op == IR_SEXT) { in ir_sccp()
2219 } else if (!ir_sccp_fold(ctx, _values, i, insn->opt, insn->op1, insn->op2, insn->op3)) { in ir_sccp()
2223 insn = &ctx->ir_base[i]; in ir_sccp()
2224 if (insn->op == IR_FP2FP || insn->op == IR_FP2INT || insn->op == IR_TRUNC in ir_sccp()
2225 || insn->op == IR_ZEXT || insn->op == IR_SEXT) { in ir_sccp()
2233 if (insn->op == IR_MERGE || insn->op == IR_BEGIN) { in ir_sccp()
2236 if (insn->op == IR_MERGE || insn->op == IR_LOOP_BEGIN) { in ir_sccp()
2239 n = insn->inputs_count; in ir_sccp()
2245 for (p = insn->ops + 1; n > 0; p++, n--) { in ir_sccp()
2261 IR_ASSERT(insn->op == IR_START || IR_IS_FEASIBLE(insn->op1)); in ir_sccp()
2265 IR_ASSERT(insn->op1 > 0); in ir_sccp()
2266 if (_values[insn->op1].optx == IR_TOP) { in ir_sccp()
2270 if (insn->op == IR_IF) { 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()
2307 } else if (insn->op == IR_SWITCH) { 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()
2355 } else if (ir_is_dead_load_ex(ctx, i, flags, insn)) { in ir_sccp()
2363 if (IR_OP_HAS_VAR_INPUTS(flags) && (n = insn->inputs_count) > 3) { in ir_sccp()
2367 for (j = 2, p = insn->ops + j; j <= n; j++, p++) { in ir_sccp()
2376 use = insn->op2; in ir_sccp()
2383 use = insn->op3; in ir_sccp()
2442 insn = &ctx->ir_base[i]; in ir_sccp()
2443 if (ir_op_flags[insn->op] & (IR_OP_FLAG_DATA|IR_OP_FLAG_MEM)) { in ir_sccp()
2444 if (insn->op != IR_PARAM && (insn->op != IR_VAR || _values[insn->op1].op == IR_TOP)) { in ir_sccp()
2448 if (ir_op_flags[insn->op] & IR_OP_FLAG_TERMINATOR) { in ir_sccp()
2452 ctx->ir_base[1].op1 = insn->op3; in ir_sccp()
2456 ctx->ir_base[prev].op3 = insn->op3; in ir_sccp()
2485 insn = &ctx->ir_base[i]; in ir_sccp()
2486 if (IR_IS_FOLDABLE_OP(insn->op)) { in ir_sccp()
2488 if (insn->op == IR_PHI) { in ir_sccp()
2489 ir_bitqueue_add(&worklist2, insn->op1); in ir_sccp()
2493 insn = &ctx->ir_base[i]; in ir_sccp()
2494 switch (insn->op) { in ir_sccp()
2496 if (insn->type == IR_FLOAT) { in ir_sccp()
2497 if (ir_may_promote_d2f(ctx, insn->op1)) { in ir_sccp()
2498 ir_ref ref = ir_promote_d2f(ctx, insn->op1, i); in ir_sccp()
2499 insn->op1 = ref; in ir_sccp()
2504 if (ir_may_promote_f2d(ctx, insn->op1)) { in ir_sccp()
2505 ir_ref ref = ir_promote_f2d(ctx, insn->op1, i); in ir_sccp()
2506 insn->op1 = ref; in ir_sccp()
2513 if (ctx->ir_base[insn->op1].type == IR_DOUBLE) { in ir_sccp()
2514 if (ir_may_promote_d2f(ctx, insn->op1)) { in ir_sccp()
2515 insn->op1 = ir_promote_d2f(ctx, insn->op1, i); in ir_sccp()
2518 if (ir_may_promote_f2d(ctx, insn->op1)) { in ir_sccp()
2519 insn->op1 = ir_promote_f2d(ctx, insn->op1, i); in ir_sccp()
2524 if (ir_may_promote_i2i(ctx, insn->type, insn->op1)) { in ir_sccp()
2525 ir_ref ref = ir_promote_i2i(ctx, insn->type, insn->op1, i); in ir_sccp()
2526 insn->op1 = ref; in ir_sccp()
2533 if (ir_try_promote_ext(ctx, i, insn, &worklist2)) { in ir_sccp()
2545 } else if (ir_op_flags[insn->op] & IR_OP_FLAG_BB_START) { in ir_sccp()
2548 } else if (insn->op == IR_BEGIN) { in ir_sccp()
2549 if (ctx->ir_base[insn->op1].op == IR_END in ir_sccp()
2551 ir_merge_blocks(ctx, insn->op1, i, &worklist2); in ir_sccp()
2553 } else if (insn->op == IR_MERGE) { in ir_sccp()
2554 ir_optimize_merge(ctx, i, insn, &worklist2); in ir_sccp()
2560 ctx->ir_base[next].op1 = insn->op1; in ir_sccp()
2561 ir_use_list_replace_one(ctx, insn->op1, i, next); in ir_sccp()
2562 insn->op1 = IR_UNUSED; in ir_sccp()