diff options
author | Ruiling Song <ruiling.song@intel.com> | 2014-11-10 11:31:21 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-11-10 14:07:14 +0800 |
commit | 8b98e5741a9235a5400d77df5247f15716b05c7b (patch) | |
tree | 9d9d5b69e2ab458c64c0d0fc6032d7afea96041c /backend | |
parent | 084a9f301c3ccdc8f278c69e8d5e652d17a1a840 (diff) |
GBE: Fix a bitcast from float vector to wide interger issue in legalize pass.
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@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Diffstat (limited to 'backend')
-rw-r--r-- | backend/src/llvm/llvm_legalize.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/backend/src/llvm/llvm_legalize.cpp b/backend/src/llvm/llvm_legalize.cpp index ea0e75ae..bb09eab2 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); } |