@@ -4027,37 +4027,29 @@ LLVM_Util::op_1st_active_lane_of(llvm::Value* mask)
4027
4027
// Assumes mask is not empty
4028
4028
4029
4029
llvm::Type* intMaskType = nullptr ;
4030
+ llvm::Value* int_mask;
4030
4031
switch (m_vector_width) {
4031
4032
case 16 :
4032
4033
// We can just reinterpret cast a 16 bit mask to a 16 bit integer
4033
4034
// and all types are happy
4034
4035
intMaskType = type_int16 ();
4036
+ int_mask = builder ().CreateBitCast (mask, intMaskType);
4035
4037
break ;
4036
4038
case 8 :
4037
4039
// We can just reinterpret cast a 8 bit mask to a 8 bit integer
4038
4040
// and all types are happy
4039
4041
intMaskType = type_int8 ();
4042
+ int_mask = builder ().CreateBitCast (mask, intMaskType);
4040
4043
break ;
4041
4044
case 4 : {
4042
4045
intMaskType = type_int8 ();
4043
-
4044
- llvm::Value* mask_as_int = mask4_as_int8 (mask);
4045
-
4046
- // Count trailing zeros, least significant
4047
- llvm::Type* types[] = { intMaskType };
4048
- llvm::Function* func_cttz
4049
- = llvm::Intrinsic::getDeclaration (module (), llvm::Intrinsic::cttz,
4050
- toArrayRef (types));
4051
-
4052
- llvm::Value* args[2 ] = { mask_as_int, constant_bool (true ) };
4053
-
4054
- llvm::Value* firstNonZeroIndex = builder ().CreateCall (func_cttz,
4055
- toArrayRef (args));
4056
- return firstNonZeroIndex;
4057
-
4046
+ int_mask = mask4_as_int8 (mask);
4058
4047
break ;
4059
4048
}
4060
- default : OSL_ASSERT (0 && " unsupported native bit mask width" );
4049
+ default : {
4050
+ OSL_ASSERT (0 && " unsupported native bit mask width" );
4051
+ int_mask = 0 ;
4052
+ }
4061
4053
};
4062
4054
4063
4055
// Count trailing zeros, least significant
@@ -4066,8 +4058,7 @@ LLVM_Util::op_1st_active_lane_of(llvm::Value* mask)
4066
4058
= llvm::Intrinsic::getDeclaration (module (), llvm::Intrinsic::cttz,
4067
4059
toArrayRef (types));
4068
4060
4069
- llvm::Value* int_mask = builder ().CreateBitCast (mask, intMaskType);
4070
- llvm::Value* args[2 ] = { int_mask, constant_bool (true ) };
4061
+ llvm::Value* args[2 ] = { int_mask, constant_bool (true ) };
4071
4062
4072
4063
llvm::Value* firstNonZeroIndex = builder ().CreateCall (func_cttz,
4073
4064
toArrayRef (args));
0 commit comments