[llvm-commits] [llvm-gcc-4.0] r46276 - /llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Chris Lattner
sabre at nondot.org
Wed Jan 23 11:04:14 PST 2008
Author: lattner
Date: Wed Jan 23 13:04:14 2008
New Revision: 46276
URL: http://llvm.org/viewvc/llvm-project?rev=46276&view=rev
Log:
Fix rdar://5701047, llvm-gcc crashes on this testcase on ppc:
typedef __attribute__((altivec(vector__))) float vFloat;
static const vFloat _minusZero = ((const vFloat) (-0.0f));
vFloat x;
void foo(vFloat f0, vFloat f1) {
x = vec_vmaddfp(f0, f1, _minusZero);
}
vector_cst's are supposed to be zerofilled if insufficient elements are specified.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=46276&r1=46275&r2=46276&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Wed Jan 23 13:04:14 2008
@@ -5962,6 +5962,15 @@
std::vector<Constant*> Elts;
for (tree elt = TREE_VECTOR_CST_ELTS(exp); elt; elt = TREE_CHAIN(elt))
Elts.push_back(Convert(TREE_VALUE(elt)));
+
+ // The vector should be zero filled if insufficient elements are provided.
+ if (Elts.size() < TYPE_VECTOR_SUBPARTS(TREE_TYPE(exp))) {
+ tree EltType = TREE_TYPE(TREE_TYPE(exp));
+ Constant *Zero = Constant::getNullValue(ConvertType(EltType));
+ while (Elts.size() < TYPE_VECTOR_SUBPARTS(TREE_TYPE(exp)))
+ Elts.push_back(Zero);
+ }
+
return ConstantVector::get(Elts);
} else {
return Constant::getNullValue(ConvertType(TREE_TYPE(exp)));
More information about the llvm-commits
mailing list