Commit 709f69b2 by Nicolas Capens Committed by Nicolas Capens

Refactor checking for sub-vector intrinsics.

Bug swiftshader:48 Change-Id: I05352fd64cb2e5a929295ff6a8f6196da7fdbb4b Reviewed-on: https://swiftshader-review.googlesource.com/10949Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent bea4dce9
......@@ -38,6 +38,8 @@ namespace
void deleteInstruction(Ice::Inst *instruction);
bool isDead(Ice::Inst *instruction);
static const Ice::InstIntrinsicCall *asLoadSubVector(const Ice::Inst *instruction);
static const Ice::InstIntrinsicCall *asStoreSubVector(const Ice::Inst *instruction);
static bool isLoad(const Ice::Inst &instruction);
static bool isStore(const Ice::Inst &instruction);
static Ice::Operand *storeAddress(const Ice::Inst *instruction);
......@@ -464,34 +466,50 @@ namespace
return false;
}
bool Optimizer::isLoad(const Ice::Inst &instruction)
const Ice::InstIntrinsicCall *Optimizer::asLoadSubVector(const Ice::Inst *instruction)
{
if(llvm::isa<Ice::InstLoad>(&instruction))
if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction))
{
return true;
if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::LoadSubVector)
{
return instrinsic;
}
}
if(auto intrinsicCall = llvm::dyn_cast<Ice::InstIntrinsicCall>(&instruction))
return nullptr;
}
const Ice::InstIntrinsicCall *Optimizer::asStoreSubVector(const Ice::Inst *instruction)
{
if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction))
{
return intrinsicCall->getIntrinsicInfo().ID == Ice::Intrinsics::LoadSubVector;
if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::StoreSubVector)
{
return instrinsic;
}
}
return false;
return nullptr;
}
bool Optimizer::isStore(const Ice::Inst &instruction)
bool Optimizer::isLoad(const Ice::Inst &instruction)
{
if(llvm::isa<Ice::InstStore>(&instruction))
if(llvm::isa<Ice::InstLoad>(&instruction))
{
return true;
}
if(auto intrinsicCall = llvm::dyn_cast<Ice::InstIntrinsicCall>(&instruction))
return asLoadSubVector(&instruction) != nullptr;
}
bool Optimizer::isStore(const Ice::Inst &instruction)
{
if(llvm::isa<Ice::InstStore>(&instruction))
{
return intrinsicCall->getIntrinsicInfo().ID == Ice::Intrinsics::StoreSubVector;
return true;
}
return false;
return asStoreSubVector(&instruction) != nullptr;
}
Ice::Operand *Optimizer::storeAddress(const Ice::Inst *instruction)
......@@ -503,12 +521,9 @@ namespace
return store->getAddr();
}
if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction))
if(auto *storeSubVector = asStoreSubVector(instruction))
{
if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::StoreSubVector)
{
return instrinsic->getSrc(2);
}
return storeSubVector->getSrc(2);
}
return nullptr;
......@@ -523,12 +538,9 @@ namespace
return load->getSourceAddress();
}
if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction))
if(auto *loadSubVector = asLoadSubVector(instruction))
{
if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::LoadSubVector)
{
return instrinsic->getSrc(1);
}
return loadSubVector->getSrc(1);
}
return nullptr;
......@@ -543,12 +555,9 @@ namespace
return store->getData();
}
if(auto *instrinsic = llvm::dyn_cast<Ice::InstIntrinsicCall>(instruction))
if(auto *storeSubVector = asStoreSubVector(instruction))
{
if(instrinsic->getIntrinsicInfo().ID == Ice::Intrinsics::StoreSubVector)
{
return instrinsic->getSrc(1);
}
return storeSubVector->getSrc(1);
}
return nullptr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment