@@ -88,6 +88,7 @@ import {
8888} from "./program" ;
8989
9090import {
91+ findUsedLocals ,
9192 FlowFlags ,
9293 LocalFlags
9394} from "./flow" ;
@@ -1185,7 +1186,7 @@ function builtin_rotl(ctx: BuiltinContext): ExpressionRef {
11851186 case TypeKind . U16 : {
11861187 // (value << (shift & mask)) | (value >>> ((0 - shift) & mask))
11871188 let flow = compiler . currentFlow ;
1188- let temp1 = flow . getTempLocal ( type ) ;
1189+ let temp1 = flow . getTempLocal ( type , findUsedLocals ( arg1 ) ) ;
11891190 flow . setLocalFlag ( temp1 . index , LocalFlags . WRAPPED ) ;
11901191 let temp2 = flow . getTempLocal ( type ) ;
11911192 flow . setLocalFlag ( temp2 . index , LocalFlags . WRAPPED ) ;
@@ -1266,7 +1267,7 @@ function builtin_rotr(ctx: BuiltinContext): ExpressionRef {
12661267 case TypeKind . U16 : {
12671268 // (value >>> (shift & mask)) | (value << ((0 - shift) & mask))
12681269 let flow = compiler . currentFlow ;
1269- let temp1 = flow . getTempLocal ( type ) ;
1270+ let temp1 = flow . getTempLocal ( type , findUsedLocals ( arg1 ) ) ;
12701271 flow . setLocalFlag ( temp1 . index , LocalFlags . WRAPPED ) ;
12711272 let temp2 = flow . getTempLocal ( type ) ;
12721273 flow . setLocalFlag ( temp2 . index , LocalFlags . WRAPPED ) ;
@@ -1484,7 +1485,7 @@ function builtin_max(ctx: BuiltinContext): ExpressionRef {
14841485 if ( op != - 1 ) {
14851486 let flow = compiler . currentFlow ;
14861487 let nativeType = type . toNativeType ( ) ;
1487- let temp1 = flow . getTempLocal ( type ) ;
1488+ let temp1 = flow . getTempLocal ( type , findUsedLocals ( arg1 ) ) ;
14881489 flow . setLocalFlag ( temp1 . index , LocalFlags . WRAPPED ) ;
14891490 let temp2 = flow . getTempLocal ( type ) ;
14901491 flow . setLocalFlag ( temp2 . index , LocalFlags . WRAPPED ) ;
@@ -1563,7 +1564,7 @@ function builtin_min(ctx: BuiltinContext): ExpressionRef {
15631564 if ( op != - 1 ) {
15641565 let flow = compiler . currentFlow ;
15651566 let nativeType = type . toNativeType ( ) ;
1566- let temp1 = flow . getTempLocal ( type ) ;
1567+ let temp1 = flow . getTempLocal ( type , findUsedLocals ( arg1 ) ) ;
15671568 flow . setLocalFlag ( temp1 . index , LocalFlags . WRAPPED ) ;
15681569 let temp2 = flow . getTempLocal ( type ) ;
15691570 flow . setLocalFlag ( temp2 . index , LocalFlags . WRAPPED ) ;
0 commit comments