File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -476,9 +476,29 @@ bool GASPropagator::visitSelect(SelectInst& I) {
476
476
if (!ASCI || ASCI->getSrcTy () != NonGASTy)
477
477
return false ;
478
478
479
+ // Change select operands to non-GAS
479
480
TheUse->set (TheVal);
480
481
TheOtherUse->set (ASCI->getOperand (0 ));
481
482
483
+ // Handle select return type
484
+ BuilderType::InsertPointGuard Guard (*IRB);
485
+ IRB->SetInsertPoint (&(*std::next (BasicBlock::iterator (&I))));
486
+
487
+ PointerType* DstPtrTy = cast<PointerType>(I.getType ());
488
+ PointerType* NonGASPtrTy = dyn_cast<PointerType>(NonGASTy);
489
+
490
+ // Push 'addrspacecast' forward by changing the select return type to non-GAS pointer
491
+ // followed by a new 'addrspacecast' to GAS
492
+ PointerType* TransPtrTy = PointerType::get (DstPtrTy->getElementType (), NonGASPtrTy->getAddressSpace ());
493
+ I.mutateType (TransPtrTy);
494
+ Value* NewPtr = IRB->CreateAddrSpaceCast (&I, DstPtrTy);
495
+
496
+ for (auto UI = I.use_begin (), UE = I.use_end (); UI != UE;) {
497
+ Use& U = *UI++;
498
+ if (U.getUser () == NewPtr)
499
+ continue ;
500
+ U.set (NewPtr);
501
+ }
482
502
return true ;
483
503
}
484
504
You can’t perform that action at this time.
0 commit comments