@@ -57,7 +57,7 @@ func testNondifferentiableTupleElementAddr<T>(_ x: T) -> T {
57
57
// CHECK: [ACTIVE] %56 = tuple_element_addr %55 : $*(Int, Int, (T, Int), Int), 2
58
58
// CHECK: [ACTIVE] %57 = tuple_element_addr %56 : $*(T, Int), 0
59
59
60
- // Check activity analysis for `array.uninitialized_intrinsic` applications.
60
+ // Check `array.uninitialized_intrinsic` applications.
61
61
62
62
@differentiable
63
63
func testArrayUninitializedIntrinsic( _ x: Float , _ y: Float ) -> [ Float ] {
@@ -93,10 +93,10 @@ func testArrayUninitializedIntrinsicGeneric<T>(_ x: T, _ y: T) -> [T] {
93
93
// CHECK: [VARIED] %11 = integer_literal $Builtin.Word, 1
94
94
// CHECK: [VARIED] %12 = index_addr %9 : $*T, %11 : $Builtin.Word
95
95
96
- // TF-781: check activity analysis for active local address + nested conditionals.
96
+ // TF-781: check active local address + nested conditionals.
97
97
98
98
@differentiable ( wrt: x)
99
- func TF_781_function ( _ x: Float , _ y: Float ) -> Float {
99
+ func TF_781 ( _ x: Float , _ y: Float ) -> Float {
100
100
var result = y
101
101
if true {
102
102
if true {
@@ -106,7 +106,7 @@ func TF_781_function(_ x: Float, _ y: Float) -> Float {
106
106
return result
107
107
}
108
108
109
- // CHECK-LABEL: [AD] Activity info for ${{.*}}TF_781_function {{.*}} at (source=0 parameters=(0))
109
+ // CHECK-LABEL: [AD] Activity info for ${{.*}}TF_781 {{.*}} at (source=0 parameters=(0))
110
110
// CHECK: [ACTIVE] %0 = argument of bb0 : $Float
111
111
// CHECK: [USEFUL] %1 = argument of bb0 : $Float
112
112
// CHECK: [ACTIVE] %4 = alloc_stack $Float, var, name "result"
@@ -116,3 +116,41 @@ func TF_781_function(_ x: Float, _ y: Float) -> Float {
116
116
// CHECK: [ACTIVE] %24 = begin_access [modify] [static] %4 : $*Float
117
117
// CHECK: [ACTIVE] %31 = begin_access [read] [static] %4 : $*Float
118
118
// CHECK: [ACTIVE] %32 = load [trivial] %31 : $*Float
119
+
120
+ // TF-954: check nested conditionals and addresses.
121
+
122
+ @differentiable
123
+ func TF_954( _ x: Float ) -> Float {
124
+ var outer = x
125
+ outerIf: if true {
126
+ var inner = outer
127
+ inner = inner * x // check activity of this `apply`
128
+ if false {
129
+ break outerIf
130
+ }
131
+ outer = inner
132
+ }
133
+ return outer
134
+ }
135
+
136
+ // CHECK-LABEL: [AD] Activity info for ${{.*}}TF_954{{.*}} at (source=0 parameters=(0))
137
+ // CHECK: bb0:
138
+ // CHECK: [ACTIVE] %0 = argument of bb0 : $Float
139
+ // CHECK: [ACTIVE] %2 = alloc_stack $Float, var, name "outer"
140
+ // CHECK: bb1:
141
+ // CHECK: [ACTIVE] %10 = alloc_stack $Float, var, name "inner"
142
+ // CHECK: [ACTIVE] %11 = begin_access [read] [static] %2 : $*Float
143
+ // CHECK: [NONE] %14 = metatype $@thin Float.Type
144
+ // CHECK: [ACTIVE] %15 = begin_access [read] [static] %10 : $*Float
145
+ // CHECK: [VARIED] %16 = load [trivial] %15 : $*Float
146
+ // CHECK: [NONE] // function_ref static Float.* infix(_:_:)
147
+ // CHECK: %18 = function_ref @$sSf1moiyS2f_SftFZ : $@convention(method) (Float, Float, @thin Float.Type) -> Float
148
+ // CHECK: [VARIED] %19 = apply %18(%16, %0, %14) : $@convention(method) (Float, Float, @thin Float.Type) -> Float
149
+ // CHECK: [ACTIVE] %20 = begin_access [modify] [static] %10 : $*Float
150
+ // CHECK: bb3:
151
+ // CHECK: [ACTIVE] %31 = begin_access [read] [static] %10 : $*Float
152
+ // CHECK: [ACTIVE] %32 = load [trivial] %31 : $*Float
153
+ // CHECK: [ACTIVE] %34 = begin_access [modify] [static] %2 : $*Float
154
+ // CHECK: bb5:
155
+ // CHECK: [ACTIVE] %40 = begin_access [read] [static] %2 : $*Float
156
+ // CHECK: [ACTIVE] %41 = load [trivial] %40 : $*Float
0 commit comments