@@ -52,4 +52,48 @@ module {
5252 } -> !secret.secret <i32 >
5353 return %0 : !secret.secret <i32 >
5454 }
55+
56+ // CHECK: @pt_multiple_uses
57+ // CHECK-SAME: (%[[arg0:.*]]: !secret.secret<i16> {mgmt.mgmt = #mgmt.mgmt<level = 2>},
58+ // CHECK-SAME: %[[arg1:.*]]: i16)
59+ func.func @pt_multiple_uses (%arg0: !secret.secret <i16 >, %arg1: i16 ) -> (!secret.secret <i16 >) {
60+ // CHECK: %[[v0:.*]] = mgmt.init %[[arg1]] {mgmt.mgmt = #mgmt.mgmt<level = 2>} : i16
61+ // CHECK: %[[v1:.*]] = mgmt.init %[[arg1]] {mgmt.mgmt = #mgmt.mgmt<level = 1>} : i16
62+ %0 = secret.generic (%arg0: !secret.secret <i16 >) {
63+ ^body (%input0: i16 ):
64+ // CHECK: arith.addi
65+ // CHECK-SAME: %[[v0]]
66+ %1 = arith.addi %input0 , %arg1 : i16
67+ // CHECK: arith.muli
68+ %2 = arith.muli %1 , %1 : i16
69+ // CHECK: arith.muli
70+ // CHECK-SAME: %[[v1]]
71+ %3 = arith.muli %2 , %arg1 : i16
72+ secret.yield %3 : i16
73+ } -> !secret.secret <i16 >
74+ return %0 : !secret.secret <i16 >
75+ }
76+
77+ // CHECK: @pt_multiple_uses_2
78+ // CHECK-SAME: (%[[arg0:.*]]: !secret.secret<i16> {mgmt.mgmt = #mgmt.mgmt<level = 2>},
79+ // CHECK-SAME: %[[arg1:.*]]: i16)
80+ func.func @pt_multiple_uses_2 (%arg0: !secret.secret <i16 >, %arg1: i16 ) -> (!secret.secret <i16 >) {
81+ // CHECK: %[[v0:.*]] = mgmt.init %[[arg1]] {mgmt.mgmt = #mgmt.mgmt<level = 2>} : i16
82+ // Note: these two mgmt.init should not merge, as later optimization like lazy relinearization
83+ // or populate-scale will make them different.
84+ // CHECK: %[[v1:.*]] = mgmt.init %[[arg1]] {mgmt.mgmt = #mgmt.mgmt<level = 2>} : i16
85+ %0 = secret.generic (%arg0: !secret.secret <i16 >) {
86+ ^body (%input0: i16 ):
87+ // CHECK: arith.addi
88+ // CHECK-SAME: %[[v0]]
89+ %1 = arith.addi %input0 , %arg1 : i16
90+ // CHECK: arith.muli
91+ %2 = arith.muli %1 , %1 : i16
92+ // CHECK: arith.addi
93+ // CHECK-SAME: %[[v1]]
94+ %3 = arith.addi %2 , %arg1 : i16
95+ secret.yield %3 : i16
96+ } -> !secret.secret <i16 >
97+ return %0 : !secret.secret <i16 >
98+ }
5599}
0 commit comments