gallivm: constant building for scalar zero

This commit is contained in:
Brian Paul
2010-03-10 18:06:02 -07:00
parent a75254dda9
commit 22bb7ffd04
+10 -2
View File
@@ -221,8 +221,16 @@ lp_build_undef(struct lp_type type)
LLVMValueRef
lp_build_zero(struct lp_type type)
{
LLVMTypeRef vec_type = lp_build_vec_type(type);
return LLVMConstNull(vec_type);
if (type.length == 1) {
if (type.floating)
return LLVMConstReal(LLVMFloatType(), 0.0);
else
return LLVMConstInt(LLVMIntType(type.width), 0, 0);
}
else {
LLVMTypeRef vec_type = lp_build_vec_type(type);
return LLVMConstNull(vec_type);
}
}