projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add target hook for whether it is profitable to reduce load widths
[oota-llvm.git]
/
lib
/
Target
/
R600
/
AMDGPUPromoteAlloca.cpp
diff --git
a/lib/Target/R600/AMDGPUPromoteAlloca.cpp
b/lib/Target/R600/AMDGPUPromoteAlloca.cpp
index 8e85b03d4eb1e76574ae601b3cd2ee577a399c57..b81fef47d55a3241a407c49adc100a4af06aa255 100644
(file)
--- a/
lib/Target/R600/AMDGPUPromoteAlloca.cpp
+++ b/
lib/Target/R600/AMDGPUPromoteAlloca.cpp
@@
-234,7
+234,8
@@
static bool tryPromoteAllocaToVector(AllocaInst *Alloca) {
return true;
}
return true;
}
-static void collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) {
+static bool collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) {
+ bool Success = true;
for (User *User : Val->users()) {
if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
continue;
for (User *User : Val->users()) {
if(std::find(WorkList.begin(), WorkList.end(), User) != WorkList.end())
continue;
@@
-242,11
+243,20
@@
static void collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) {
WorkList.push_back(User);
continue;
}
WorkList.push_back(User);
continue;
}
+
+ // FIXME: Correctly handle ptrtoint instructions.
+ Instruction *UseInst = dyn_cast<Instruction>(User);
+ if (UseInst && UseInst->getOpcode() == Instruction::PtrToInt)
+ return false;
+
if (!User->getType()->isPointerTy())
continue;
if (!User->getType()->isPointerTy())
continue;
+
WorkList.push_back(User);
WorkList.push_back(User);
- collectUsesWithPtrTypes(User, WorkList);
+
+ Success &= collectUsesWithPtrTypes(User, WorkList);
}
}
+ return Success;
}
void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
}
void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
@@
-274,6
+284,13
@@
void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
return;
}
return;
}
+ std::vector<Value*> WorkList;
+
+ if (!collectUsesWithPtrTypes(&I, WorkList)) {
+ DEBUG(dbgs() << " Do not know how to convert all uses\n");
+ return;
+ }
+
DEBUG(dbgs() << "Promoting alloca to local memory\n");
LocalMemAvailable -= AllocaSize;
DEBUG(dbgs() << "Promoting alloca to local memory\n");
LocalMemAvailable -= AllocaSize;
@@
-320,10
+337,6
@@
void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
I.replaceAllUsesWith(Offset);
I.eraseFromParent();
I.replaceAllUsesWith(Offset);
I.eraseFromParent();
- std::vector<Value*> WorkList;
-
- collectUsesWithPtrTypes(Offset, WorkList);
-
for (std::vector<Value*>::iterator i = WorkList.begin(),
e = WorkList.end(); i != e; ++i) {
Value *V = *i;
for (std::vector<Value*>::iterator i = WorkList.begin(),
e = WorkList.end(); i != e; ++i) {
Value *V = *i;