@@ -2489,14 +2489,15 @@ def test_store_to_disjoint_receiver_does_not_kill_load
24892489 HIR
24902490 end
24912491
2492- def test_store_to_same_slot_kills_prior_load
2492+ def test_store_to_maybe_aliasing_receiver_kills_prior_load
24932493 fun = Function . new ( "test" )
24942494 bb0 = fun . new_block
2495- obj = fun . push_insn ( bb0 , Param . new ( 0 , Types ::BasicObject ) )
2495+ recv_a = fun . push_insn ( bb0 , Param . new ( 0 , Types ::BasicObject ) )
2496+ recv_b = fun . push_insn ( bb0 , Param . new ( 1 , Types ::BasicObject ) )
24962497 val = fun . push_insn ( bb0 , Const . new ( 5 , Types ::Fixnum . with_const ( 5 ) ) )
2497- load1 = fun . push_insn ( bb0 , LoadField . new ( obj , :x ) )
2498- fun . push_insn ( bb0 , StoreField . new ( obj , :x , val ) )
2499- load2 = fun . push_insn ( bb0 , LoadField . new ( obj , :x ) )
2498+ load1 = fun . push_insn ( bb0 , LoadField . new ( recv_a , :x ) )
2499+ fun . push_insn ( bb0 , StoreField . new ( recv_b , :x , val ) )
2500+ load2 = fun . push_insn ( bb0 , LoadField . new ( recv_a , :x ) )
25002501 add = fun . push_insn ( bb0 , FixnumAdd . new ( load1 , load2 , nil ) )
25012502 fun . push_insn ( bb0 , Return . new ( add ) )
25022503
@@ -2505,13 +2506,13 @@ def test_store_to_same_slot_kills_prior_load
25052506
25062507 assert_hir_text fun . to_s , <<~HIR
25072508 fn test:
2508- bb0(v0:BasicObject):
2509- v1 :Fixnum[5] = Const 5
2510- v2 :BasicObject = LoadField v0, :x
2511- StoreField v0 , :x, v1
2512- v4 :BasicObject = LoadField v0, :x
2513- v5 :Fixnum = FixnumAdd v2, v4
2514- Return v5
2509+ bb0(v0:BasicObject, v1:BasicObject ):
2510+ v2 :Fixnum[5] = Const 5
2511+ v3 :BasicObject = LoadField v0, :x
2512+ StoreField v1 , :x, v2
2513+ v5 :BasicObject = LoadField v0, :x
2514+ v6 :Fixnum = FixnumAdd v3, v5
2515+ Return v6
25152516 HIR
25162517 end
25172518 end
0 commit comments