@@ -13690,7 +13690,7 @@ mod hir_opt_tests {
1369013690 }
1369113691
1369213692 #[ test]
13693- fn test_double_store_removal ( ) {
13693+ fn test_double_store_with_removal ( ) {
1369413694 eval ( "
1369513695 class C
1369613696 def initialize
@@ -13732,4 +13732,156 @@ mod hir_opt_tests {
1373213732 Return v13
1373313733 " ) ;
1373413734 }
13735+
13736+ #[ test]
13737+ fn test_double_store_no_removal_with_alias_between ( ) {
13738+ eval ( "
13739+ class C
13740+ def initialize
13741+ a = 1
13742+ @a = a
13743+ @b = a
13744+ @a = a
13745+ end
13746+ end
13747+
13748+ C.new
13749+ " ) ;
13750+ assert_snapshot ! ( hir_string_proc( "C.instance_method(:initialize)" ) , @r"
13751+ fn initialize@<compiled>:4:
13752+ bb1():
13753+ EntryPoint interpreter
13754+ v1:BasicObject = LoadSelf
13755+ v2:NilClass = Const Value(nil)
13756+ Jump bb3(v1, v2)
13757+ bb2():
13758+ EntryPoint JIT(0)
13759+ v5:BasicObject = LoadArg :self@0
13760+ v6:NilClass = Const Value(nil)
13761+ Jump bb3(v5, v6)
13762+ bb3(v8:BasicObject, v9:NilClass):
13763+ v13:Fixnum[1] = Const Value(1)
13764+ PatchPoint SingleRactorMode
13765+ v43:HeapBasicObject = GuardType v8, HeapBasicObject
13766+ v44:CShape = LoadField v43, :_shape_id@0x1000
13767+ v45:CShape[0x1001] = GuardBitEquals v44, CShape(0x1001)
13768+ StoreField v43, :@a@0x1002, v13
13769+ WriteBarrier v43, v13
13770+ v48:CShape[0x1003] = Const CShape(0x1003)
13771+ StoreField v43, :_shape_id@0x1000, v48
13772+ v20:HeapBasicObject = RefineType v8, HeapBasicObject
13773+ PatchPoint NoEPEscape(initialize)
13774+ PatchPoint SingleRactorMode
13775+ StoreField v20, :@b@0x1004, v13
13776+ WriteBarrier v20, v13
13777+ v55:CShape[0x1005] = Const CShape(0x1005)
13778+ StoreField v20, :_shape_id@0x1000, v55
13779+ v28:HeapBasicObject = RefineType v20, HeapBasicObject
13780+ PatchPoint NoEPEscape(initialize)
13781+ PatchPoint SingleRactorMode
13782+ WriteBarrier v28, v13
13783+ CheckInterrupts
13784+ Return v13
13785+ " ) ;
13786+ }
13787+
13788+ #[ test]
13789+ fn test_double_store_with_removal_and_insns_between ( ) {
13790+ eval ( "
13791+ class C
13792+ def initialize
13793+ a = 1
13794+ @a = a
13795+ b = 5
13796+ b += a
13797+ @a = a
13798+ end
13799+ end
13800+
13801+ C.new
13802+ " ) ;
13803+ assert_snapshot ! ( hir_string_proc( "C.instance_method(:initialize)" ) , @r"
13804+ fn initialize@<compiled>:4:
13805+ bb1():
13806+ EntryPoint interpreter
13807+ v1:BasicObject = LoadSelf
13808+ v2:NilClass = Const Value(nil)
13809+ v3:NilClass = Const Value(nil)
13810+ Jump bb3(v1, v2, v3)
13811+ bb2():
13812+ EntryPoint JIT(0)
13813+ v6:BasicObject = LoadArg :self@0
13814+ v7:NilClass = Const Value(nil)
13815+ v8:NilClass = Const Value(nil)
13816+ Jump bb3(v6, v7, v8)
13817+ bb3(v10:BasicObject, v11:NilClass, v12:NilClass):
13818+ v16:Fixnum[1] = Const Value(1)
13819+ PatchPoint SingleRactorMode
13820+ v49:HeapBasicObject = GuardType v10, HeapBasicObject
13821+ v50:CShape = LoadField v49, :_shape_id@0x1000
13822+ v51:CShape[0x1001] = GuardBitEquals v50, CShape(0x1001)
13823+ StoreField v49, :@a@0x1002, v16
13824+ WriteBarrier v49, v16
13825+ v54:CShape[0x1003] = Const CShape(0x1003)
13826+ StoreField v49, :_shape_id@0x1000, v54
13827+ v23:HeapBasicObject = RefineType v10, HeapBasicObject
13828+ v26:Fixnum[5] = Const Value(5)
13829+ PatchPoint NoEPEscape(initialize)
13830+ PatchPoint MethodRedefined(Integer@0x1008, +@0x1010, cme:0x1018)
13831+ v65:Fixnum[6] = Const Value(6)
13832+ IncrCounter inline_cfunc_optimized_send_count
13833+ PatchPoint SingleRactorMode
13834+ WriteBarrier v23, v16
13835+ CheckInterrupts
13836+ Return v16
13837+ " ) ;
13838+ }
13839+
13840+ #[ test]
13841+ fn test_triple_store_with_removal ( ) {
13842+ eval ( "
13843+ class C
13844+ def initialize
13845+ a = 1
13846+ @a = a
13847+ @a = a
13848+ @a = a
13849+ end
13850+ end
13851+
13852+ C.new
13853+ " ) ;
13854+ assert_snapshot ! ( hir_string_proc( "C.instance_method(:initialize)" ) , @r"
13855+ fn initialize@<compiled>:4:
13856+ bb1():
13857+ EntryPoint interpreter
13858+ v1:BasicObject = LoadSelf
13859+ v2:NilClass = Const Value(nil)
13860+ Jump bb3(v1, v2)
13861+ bb2():
13862+ EntryPoint JIT(0)
13863+ v5:BasicObject = LoadArg :self@0
13864+ v6:NilClass = Const Value(nil)
13865+ Jump bb3(v5, v6)
13866+ bb3(v8:BasicObject, v9:NilClass):
13867+ v13:Fixnum[1] = Const Value(1)
13868+ PatchPoint SingleRactorMode
13869+ v43:HeapBasicObject = GuardType v8, HeapBasicObject
13870+ v44:CShape = LoadField v43, :_shape_id@0x1000
13871+ v45:CShape[0x1001] = GuardBitEquals v44, CShape(0x1001)
13872+ StoreField v43, :@a@0x1002, v13
13873+ WriteBarrier v43, v13
13874+ v48:CShape[0x1003] = Const CShape(0x1003)
13875+ StoreField v43, :_shape_id@0x1000, v48
13876+ v20:HeapBasicObject = RefineType v8, HeapBasicObject
13877+ PatchPoint NoEPEscape(initialize)
13878+ PatchPoint SingleRactorMode
13879+ WriteBarrier v20, v13
13880+ v28:HeapBasicObject = RefineType v20, HeapBasicObject
13881+ StoreField v28, :@a@0x1002, v13
13882+ WriteBarrier v28, v13
13883+ CheckInterrupts
13884+ Return v13
13885+ " ) ;
13886+ }
1373513887}
0 commit comments