@@ -1092,6 +1092,22 @@ void ir_set_op(ir_ctx *ctx, ir_ref ref, int32_t n, ir_ref val)
1092
1092
ir_insn_set_op (insn , n , val );
1093
1093
}
1094
1094
1095
+ ir_ref ir_get_op (ir_ctx * ctx , ir_ref ref , int32_t n )
1096
+ {
1097
+ ir_insn * insn = & ctx -> ir_base [ref ];
1098
+
1099
+ #ifdef IR_DEBUG
1100
+ if (n > 3 ) {
1101
+ int32_t count ;
1102
+
1103
+ IR_ASSERT (IR_OP_HAS_VAR_INPUTS (ir_op_flags [insn -> op ]));
1104
+ count = insn -> inputs_count ;
1105
+ IR_ASSERT (n <= count );
1106
+ }
1107
+ #endif
1108
+ return ir_insn_op (insn , n );
1109
+ }
1110
+
1095
1111
ir_ref ir_param (ir_ctx * ctx , ir_type type , ir_ref region , const char * name , int pos )
1096
1112
{
1097
1113
return ir_emit (ctx , IR_OPT (IR_PARAM , type ), region , ir_str (ctx , name ), pos );
@@ -2820,6 +2836,10 @@ void _ir_VSTORE(ir_ctx *ctx, ir_ref var, ir_ref val)
2820
2836
}
2821
2837
} else if (insn -> op == IR_VLOAD ) {
2822
2838
if (insn -> op2 == var ) {
2839
+ if (ref == val ) {
2840
+ /* dead STORE */
2841
+ return ;
2842
+ }
2823
2843
break ;
2824
2844
}
2825
2845
} else if (insn -> op == IR_GUARD || insn -> op == IR_GUARD_NOT ) {
@@ -2910,6 +2930,10 @@ void _ir_STORE(ir_ctx *ctx, ir_ref addr, ir_ref val)
2910
2930
}
2911
2931
} else if (insn -> op == IR_LOAD ) {
2912
2932
if (insn -> op2 == addr ) {
2933
+ if (ref == val ) {
2934
+ /* dead STORE */
2935
+ return ;
2936
+ }
2913
2937
break ;
2914
2938
}
2915
2939
type2 = insn -> type ;
0 commit comments