@@ -118,18 +118,14 @@ class SPIRVLegalizePointerCast : public FunctionPass {
118118
119119 // Loads elements from an array and constructs a vector.
120120 Value *loadVectorFromArray (IRBuilder<> &B, FixedVectorType *TargetType,
121- ArrayType *SourceType, Value *Source) {
122- // Ensure the element types of the array and vector are the same.
123- assert (TargetType->getElementType () == SourceType->getElementType () &&
124- " Element types of array and vector must be the same." );
125-
121+ Value *Source) {
126122 // Load each element of the array.
127123 SmallVector<Value *, 4 > LoadedElements;
128124 for (unsigned i = 0 ; i < TargetType->getNumElements (); ++i) {
129125 // Create a GEP to access the i-th element of the array.
130126 SmallVector<Type *, 2 > Types = {Source->getType (), Source->getType ()};
131127 SmallVector<Value *, 4 > Args;
132- Args.push_back (B.getInt1 (true ));
128+ Args.push_back (B.getInt1 (false ));
133129 Args.push_back (Source);
134130 Args.push_back (B.getInt32 (0 ));
135131 Args.push_back (ConstantInt::get (B.getInt32Ty (), i));
@@ -143,7 +139,7 @@ class SPIRVLegalizePointerCast : public FunctionPass {
143139 }
144140
145141 // Build the vector from the loaded elements.
146- Value *NewVector = UndefValue ::get (TargetType);
142+ Value *NewVector = PoisonValue ::get (TargetType);
147143 buildAssignType (B, TargetType, NewVector);
148144
149145 for (unsigned i = 0 ; i < TargetType->getNumElements (); ++i) {
@@ -173,7 +169,7 @@ class SPIRVLegalizePointerCast : public FunctionPass {
173169 SmallVector<Type *, 2 > Types = {DstArrayPtr->getType (),
174170 DstArrayPtr->getType ()};
175171 SmallVector<Value *, 4 > Args;
176- Args.push_back (B.getInt1 (true ));
172+ Args.push_back (B.getInt1 (false ));
177173 Args.push_back (DstArrayPtr);
178174 Args.push_back (B.getInt32 (0 ));
179175 Args.push_back (ConstantInt::get (B.getInt32Ty (), i));
@@ -234,7 +230,7 @@ class SPIRVLegalizePointerCast : public FunctionPass {
234230 else if (SST && SST->getTypeAtIndex (0u ) == ToTy)
235231 Output = loadFirstValueFromAggregate (B, ToTy, OriginalOperand, LI);
236232 else if (SAT && DVT && SAT->getElementType () == DVT->getElementType ())
237- Output = loadVectorFromArray (B, DVT, SAT, OriginalOperand);
233+ Output = loadVectorFromArray (B, DVT, OriginalOperand);
238234 else
239235 llvm_unreachable (" Unimplemented implicit down-cast from load." );
240236
0 commit comments