[Beignet] [PATCH] GBE: Fix a bitcast from float vector to wide interger issue in legalize pass.
Ruiling Song
ruiling.song at intel.com
Sun Nov 9 19:31:21 PST 2014
When bitcast from <4 x float> to i128, we should not use extractelement directly.
Instead, we cast <4 x float> to <4 x i32>, then use extractelement to get
individual element.
Signed-off-by: Ruiling Song <ruiling.song at intel.com>
---
backend/src/llvm/llvm_legalize.cpp | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/backend/src/llvm/llvm_legalize.cpp b/backend/src/llvm/llvm_legalize.cpp
index ea0e75a..bb09eab 100644
--- a/backend/src/llvm/llvm_legalize.cpp
+++ b/backend/src/llvm/llvm_legalize.cpp
@@ -516,8 +516,15 @@ namespace gbe {
Type *splitTy = vecTy->getElementType();
unsigned elements = srcTy->getPrimitiveSizeInBits()/splitTy->getPrimitiveSizeInBits();
// bitcast large integer from vector, so we do extractElement to get split integer
+ unsigned splitSz = splitTy->getPrimitiveSizeInBits();
+ Value *src = p->getOperand(0);
+ // if it is cast from <4 x float> to i128
+ // we cast <4 x float> to <4 x i32> first
+ if (!splitTy->isIntegerTy())
+ src = Builder.CreateBitCast(src, VectorType::get(IntegerType::get(p->getContext(), splitSz), elements));
+
for (unsigned i = 0; i < elements; i++) {
- Value *NV = Builder.CreateExtractElement(p->getOperand(0),
+ Value *NV = Builder.CreateExtractElement(src,
ConstantInt::get(IntegerType::get(p->getContext(), 32), i));
split.push_back(NV);
}
--
1.7.10.4
More information about the Beignet
mailing list