@@ -64,17 +64,6 @@ void llvm::createMemCpyLoopKnownSize(
64
64
65
65
IRBuilder<> PLBuilder (PreLoopBB->getTerminator ());
66
66
67
- // Cast the Src and Dst pointers to pointers to the loop operand type (if
68
- // needed).
69
- PointerType *SrcOpType = PointerType::get (LoopOpType, SrcAS);
70
- PointerType *DstOpType = PointerType::get (LoopOpType, DstAS);
71
- if (SrcAddr->getType () != SrcOpType) {
72
- SrcAddr = PLBuilder.CreateBitCast (SrcAddr, SrcOpType);
73
- }
74
- if (DstAddr->getType () != DstOpType) {
75
- DstAddr = PLBuilder.CreateBitCast (DstAddr, DstOpType);
76
- }
77
-
78
67
Align PartDstAlign (commonAlignment (DstAlign, LoopOpSize));
79
68
Align PartSrcAlign (commonAlignment (SrcAlign, LoopOpSize));
80
69
@@ -137,27 +126,18 @@ void llvm::createMemCpyLoopKnownSize(
137
126
uint64_t GepIndex = BytesCopied / OperandSize;
138
127
assert (GepIndex * OperandSize == BytesCopied &&
139
128
" Division should have no Remainder!" );
140
- // Cast source to operand type and load
141
- PointerType *SrcPtrType = PointerType::get (OpTy, SrcAS);
142
- Value *CastedSrc = SrcAddr->getType () == SrcPtrType
143
- ? SrcAddr
144
- : RBuilder.CreateBitCast (SrcAddr, SrcPtrType);
129
+
145
130
Value *SrcGEP = RBuilder.CreateInBoundsGEP (
146
- OpTy, CastedSrc , ConstantInt::get (TypeOfCopyLen, GepIndex));
131
+ OpTy, SrcAddr , ConstantInt::get (TypeOfCopyLen, GepIndex));
147
132
LoadInst *Load =
148
133
RBuilder.CreateAlignedLoad (OpTy, SrcGEP, PartSrcAlign, SrcIsVolatile);
149
134
if (!CanOverlap) {
150
135
// Set alias scope for loads.
151
136
Load->setMetadata (LLVMContext::MD_alias_scope,
152
137
MDNode::get (Ctx, NewScope));
153
138
}
154
- // Cast destination to operand type and store.
155
- PointerType *DstPtrType = PointerType::get (OpTy, DstAS);
156
- Value *CastedDst = DstAddr->getType () == DstPtrType
157
- ? DstAddr
158
- : RBuilder.CreateBitCast (DstAddr, DstPtrType);
159
139
Value *DstGEP = RBuilder.CreateInBoundsGEP (
160
- OpTy, CastedDst , ConstantInt::get (TypeOfCopyLen, GepIndex));
140
+ OpTy, DstAddr , ConstantInt::get (TypeOfCopyLen, GepIndex));
161
141
StoreInst *Store = RBuilder.CreateAlignedStore (Load, DstGEP, PartDstAlign,
162
142
DstIsVolatile);
163
143
if (!CanOverlap) {
@@ -206,15 +186,6 @@ void llvm::createMemCpyLoopUnknownSize(
206
186
207
187
IRBuilder<> PLBuilder (PreLoopBB->getTerminator ());
208
188
209
- PointerType *SrcOpType = PointerType::get (LoopOpType, SrcAS);
210
- PointerType *DstOpType = PointerType::get (LoopOpType, DstAS);
211
- if (SrcAddr->getType () != SrcOpType) {
212
- SrcAddr = PLBuilder.CreateBitCast (SrcAddr, SrcOpType);
213
- }
214
- if (DstAddr->getType () != DstOpType) {
215
- DstAddr = PLBuilder.CreateBitCast (DstAddr, DstOpType);
216
- }
217
-
218
189
// Calculate the loop trip count, and remaining bytes to copy after the loop.
219
190
Type *CopyLenType = CopyLen->getType ();
220
191
IntegerType *ILengthType = dyn_cast<IntegerType>(CopyLenType);
@@ -305,22 +276,18 @@ void llvm::createMemCpyLoopUnknownSize(
305
276
ResBuilder.CreatePHI (CopyLenType, 2 , " residual-loop-index" );
306
277
ResidualIndex->addIncoming (Zero, ResHeaderBB);
307
278
308
- Value *SrcAsResLoopOpType = ResBuilder.CreateBitCast (
309
- SrcAddr, PointerType::get (ResLoopOpType, SrcAS));
310
- Value *DstAsResLoopOpType = ResBuilder.CreateBitCast (
311
- DstAddr, PointerType::get (ResLoopOpType, DstAS));
312
279
Value *FullOffset = ResBuilder.CreateAdd (RuntimeBytesCopied, ResidualIndex);
313
- Value *SrcGEP = ResBuilder. CreateInBoundsGEP (
314
- ResLoopOpType, SrcAsResLoopOpType , FullOffset);
280
+ Value *SrcGEP =
281
+ ResBuilder. CreateInBoundsGEP ( ResLoopOpType, SrcAddr , FullOffset);
315
282
LoadInst *Load = ResBuilder.CreateAlignedLoad (ResLoopOpType, SrcGEP,
316
283
PartSrcAlign, SrcIsVolatile);
317
284
if (!CanOverlap) {
318
285
// Set alias scope for loads.
319
286
Load->setMetadata (LLVMContext::MD_alias_scope,
320
287
MDNode::get (Ctx, NewScope));
321
288
}
322
- Value *DstGEP = ResBuilder. CreateInBoundsGEP (
323
- ResLoopOpType, DstAsResLoopOpType , FullOffset);
289
+ Value *DstGEP =
290
+ ResBuilder. CreateInBoundsGEP ( ResLoopOpType, DstAddr , FullOffset);
324
291
StoreInst *Store = ResBuilder.CreateAlignedStore (Load, DstGEP, PartDstAlign,
325
292
DstIsVolatile);
326
293
if (!CanOverlap) {
0 commit comments