@@ -1295,8 +1295,7 @@ Function *CLBuiltinInfo::getVectorEquivalent(const Builtin &B, unsigned Width,
12951295 if (!FixedVectorType::isValidElementType (PtrRetPointeeTy)) {
12961296 return nullptr ;
12971297 }
1298- Type *NewEleTy = FixedVectorType::get (PtrRetPointeeTy, Width);
1299- Type *NewType = PointerType::get (NewEleTy, OldPtrTy->getAddressSpace ());
1298+ Type *NewType = OldPtrTy;
13001299 TypeQualifiers NewQuals;
13011300 TypeQualifiers EleQuals = OldQuals;
13021301 NewQuals.push_back (EleQuals.pop_front ()); // Pointer qualifier
@@ -1413,9 +1412,7 @@ Function *CLBuiltinInfo::getScalarEquivalent(const Builtin &B, Module *M) {
14131412 [[maybe_unused]] auto *OldPointeeTy = BuiltinPointeeTypes[i];
14141413 assert (OldPointeeTy && OldPointeeTy == PtrRetPointeeTy &&
14151414 " Demangling inconsistency" );
1416- auto *OldVecTy = cast<FixedVectorType>(PtrRetPointeeTy);
1417- Type *NewTy = PointerType::get (OldVecTy->getElementType (),
1418- OldPtrTy->getAddressSpace ());
1415+ Type *NewTy = OldPtrTy;
14191416 TypeQualifiers NewQuals = OldQuals;
14201417 const TypeQualifier PtrQual = NewQuals.pop_front ();
14211418 const TypeQualifier VecQual = NewQuals.pop_front ();
@@ -2190,8 +2187,7 @@ Value *CLBuiltinInfo::emitBuiltinInlineVLoad(Function *F, unsigned Width,
21902187 Data = B.CreateInsertElement (Data, Lane, Index, " vload_insert" );
21912188 }
21922189 } else {
2193- Value *VecBase = B.CreateBitCast (GEPBase, PtrTy, " vload_ptr" );
2194- auto *Load = B.CreateLoad (DataTy, VecBase, false , " vload" );
2190+ auto *Load = B.CreateLoad (DataTy, GEPBase, false , " vload" );
21952191
21962192 const unsigned Align = DataTy->getScalarSizeInBits () / 8 ;
21972193 Load->setAlignment (MaybeAlign (Align).valueOrOne ());
@@ -2250,8 +2246,7 @@ Value *CLBuiltinInfo::emitBuiltinInlineVStore(Function *F, unsigned Width,
22502246 Store = B.CreateStore (Lane, GEP , false );
22512247 }
22522248 } else {
2253- Value *VecBase = B.CreateBitCast (GEPBase, PtrTy, " vstore_ptr" );
2254- Store = B.CreateStore (Data, VecBase, false );
2249+ Store = B.CreateStore (Data, GEPBase, false );
22552250
22562251 const unsigned Align = VecDataTy->getScalarSizeInBits () / 8 ;
22572252 Store->setAlignment (MaybeAlign (Align).valueOrOne ());
@@ -2279,12 +2274,10 @@ Value *CLBuiltinInfo::emitBuiltinInlineVLoadHalf(Function *F, IRBuilder<> &B,
22792274 return nullptr ;
22802275 }
22812276 Type *U16Ty = B.getInt16Ty ();
2282- Type *U16PtrTy = PointerType::get (U16Ty, PtrTy->getAddressSpace ());
2283- Value *DataPtr = B.CreateBitCast (Ptr, U16PtrTy);
22842277
22852278 // Emit the base pointer.
22862279 Value *Offset = Args[0 ];
2287- DataPtr = B.CreateGEP (U16Ty, DataPtr , Offset, " vload_base" );
2280+ Value * DataPtr = B.CreateGEP (U16Ty, Ptr , Offset, " vload_base" );
22882281
22892282 // Load a ushort.
22902283 Value *Data = B.CreateLoad (B.getInt16Ty (), DataPtr, " vload_half" );
@@ -2368,12 +2361,10 @@ Value *CLBuiltinInfo::emitBuiltinInlineVStoreHalf(Function *F, StringRef Mode,
23682361 return nullptr ;
23692362 }
23702363 auto U16Ty = B.getInt16Ty ();
2371- Type *U16PtrTy = PointerType::get (U16Ty, PtrTy->getAddressSpace ());
2372- Value *DataPtr = B.CreateBitCast (Ptr, U16PtrTy);
23732364
23742365 // Emit the base pointer.
23752366 Value *Offset = Args[1 ];
2376- DataPtr = B.CreateGEP (U16Ty, DataPtr , Offset, " vstore_base" );
2367+ Value * DataPtr = B.CreateGEP (U16Ty, Ptr , Offset, " vstore_base" );
23772368
23782369 // Store the ushort.
23792370 return B.CreateStore (Data, DataPtr);
@@ -2644,7 +2635,7 @@ Value *CLBuiltinInfo::emitBuiltinInlinePrintf(BuiltinID, IRBuilder<> &B,
26442635 // Declare printf if needed.
26452636 Function *Printf = M.getFunction (" printf" );
26462637 if (!Printf) {
2647- PointerType *PtrTy = PointerType::getUnqual (B. getInt8Ty () );
2638+ PointerType *PtrTy = B. getPtrTy ( /* AddressSpace= */ 0 );
26482639 FunctionType *PrintfTy = FunctionType::get (B.getInt32Ty (), {PtrTy}, true );
26492640 Printf =
26502641 Function::Create (PrintfTy, GlobalValue::ExternalLinkage, " printf" , &M);
0 commit comments