@@ -269,24 +269,21 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
269269
270270
271271 // Private branch
272- if (!m_ctx-> forceGlobalMemoryAllocation ())
272+ privateBlock = BasicBlock::Create (I. getContext (), " PrivateBlock " , convergeBlock-> getParent (), convergeBlock);
273273 {
274- privateBlock = BasicBlock::Create (I.getContext (), " PrivateBlock" , convergeBlock->getParent (), convergeBlock);
275- {
276- IRBuilder<> privateBuilder (privateBlock);
277- PointerType* ptrType = pointerType->getElementType ()->getPointerTo (ADDRESS_SPACE_PRIVATE);
278- Value* privatePtr = privateBuilder.CreateAddrSpaceCast (pointerOperand, ptrType);
274+ IRBuilder<> privateBuilder (privateBlock);
275+ PointerType* ptrType = pointerType->getElementType ()->getPointerTo (ADDRESS_SPACE_PRIVATE);
276+ Value* privatePtr = privateBuilder.CreateAddrSpaceCast (pointerOperand, ptrType);
279277
280- if (LoadInst* LI = dyn_cast<LoadInst>(&I))
281- {
282- privateLoad = privateBuilder.CreateAlignedLoad (privatePtr, LI->getAlignment (), LI->isVolatile (), " privateLoad" );
283- }
284- else if (StoreInst* SI = dyn_cast<StoreInst>(&I))
285- {
286- privateBuilder.CreateAlignedStore (I.getOperand (0 ), privatePtr, SI->getAlignment (), SI->isVolatile ());
287- }
288- privateBuilder.CreateBr (convergeBlock);
278+ if (LoadInst* LI = dyn_cast<LoadInst>(&I))
279+ {
280+ privateLoad = privateBuilder.CreateAlignedLoad (privatePtr, LI->getAlignment (), LI->isVolatile (), " privateLoad" );
281+ }
282+ else if (StoreInst* SI = dyn_cast<StoreInst>(&I))
283+ {
284+ privateBuilder.CreateAlignedStore (I.getOperand (0 ), privatePtr, SI->getAlignment (), SI->isVolatile ());
289285 }
286+ privateBuilder.CreateBr (convergeBlock);
290287 }
291288
292289 // Local Branch
@@ -314,14 +311,12 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
314311 globalBlock = BasicBlock::Create (I.getContext (), " GlobalBlock" , convergeBlock->getParent (), convergeBlock);
315312 {
316313 IRBuilder<> globalBuilder (globalBlock);
317- PointerType* ptrType = pointerType->getElementType ()->getPointerTo (
318- m_ctx->forceGlobalMemoryAllocation () ? ADDRESS_SPACE_GLOBAL_OR_PRIVATE : ADDRESS_SPACE_GLOBAL);
314+ PointerType* ptrType = pointerType->getElementType ()->getPointerTo (ADDRESS_SPACE_GLOBAL);
319315 Value* globalPtr = globalBuilder.CreateAddrSpaceCast (pointerOperand, ptrType);
320316
321317 if (LoadInst* LI = dyn_cast<LoadInst>(&I))
322318 {
323- globalLoad = globalBuilder.CreateAlignedLoad (globalPtr, LI->getAlignment (), LI->isVolatile (),
324- m_ctx->forceGlobalMemoryAllocation () ? " privateOrGlobalLoad" : " globalLoad" );
319+ globalLoad = globalBuilder.CreateAlignedLoad (globalPtr, LI->getAlignment (), LI->isVolatile (), " globalLoad" );
325320 }
326321 else if (StoreInst* SI = dyn_cast<StoreInst>(&I))
327322 {
@@ -333,26 +328,9 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
333328 currentBlock->getTerminator ()->eraseFromParent ();
334329 builder.SetInsertPoint (currentBlock);
335330
336-
337- // Private branch can be saved if private mem is allocated in global stateless
338- if (m_ctx->forceGlobalMemoryAllocation ())
339- {
340- SwitchInst* switchTag = builder.CreateSwitch (tag, globalBlock, 1 );
341- // Based on tag there are two cases 010: local, 000/111: global
342- switchTag->addCase (localTag, localBlock);
343-
344- if ((localLoad != nullptr ) && (globalLoad != nullptr ))
345- {
346- IRBuilder<> phiBuilder (&(*convergeBlock->begin ()));
347- PHINode* phi = phiBuilder.CreatePHI (I.getType (), 2 , I.getName ());
348- phi->addIncoming (localLoad, localBlock);
349- phi->addIncoming (globalLoad, globalBlock);
350- I.replaceAllUsesWith (phi);
351- }
352- }
353- else if (m_ctx->hasNoLocalToGenericCast ())
331+ // Local branch can be saved if there are no local to generic casts
332+ if (m_ctx->hasNoLocalToGenericCast ())
354333 {
355- // Local branch can be saved if there are no local to generic casts
356334 SwitchInst* switchTag = builder.CreateSwitch (tag, globalBlock, 1 );
357335 // Based on tag there are two cases 001: private, 000/111: global
358336 switchTag->addCase (privateTag, privateBlock);
@@ -369,7 +347,7 @@ void GenericAddressDynamicResolution::resolveGAS(Instruction& I, Value* pointerO
369347 else
370348 {
371349 SwitchInst* switchTag = builder.CreateSwitch (tag, globalBlock, 2 );
372- // Based on tag there are three cases 001: private, 010: local, 000/111: global
350+ // Based on tag there are two cases 001: private, 010: local, 000/111: global
373351 switchTag->addCase (privateTag, privateBlock);
374352 switchTag->addCase (localTag, localBlock);
375353
@@ -394,7 +372,7 @@ void GenericAddressDynamicResolution::resolveGASWithoutBranches(Instruction& I,
394372
395373 Value* nonLocalLoad = nullptr ;
396374
397- PointerType* ptrType = pointerType->getElementType ()->getPointerTo (ADDRESS_SPACE_GLOBAL_OR_PRIVATE );
375+ PointerType* ptrType = pointerType->getElementType ()->getPointerTo (ADDRESS_SPACE_GLOBAL );
398376 Value* globalPtr = builder.CreateAddrSpaceCast (pointerOperand, ptrType);
399377
400378 if (LoadInst* LI = dyn_cast<LoadInst>(&I))
0 commit comments