[llvm] Decompose gep of complex type struct to its element type (PR #107848)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 00:53:33 PDT 2024
================
@@ -1555,6 +1555,17 @@ bool GetElementPtrInst::hasAllConstantIndices() const {
return true;
}
+/// hasAllZeroIndicesExceptLast - Return true if all of the indices of this GEP
+/// are zero except the last indice.
+bool GetElementPtrInst::hasAllZeroIndicesExceptLast() const {
+ for (unsigned i = 1, e = getNumOperands() - 1; i != e; ++i) {
+ ConstantInt *Val = dyn_cast<ConstantInt>(getOperand(i));
----------------
vfdff wrote:
Do you mean something like the following one ?
```
define <4 x ptr> @decompose_complex_vector1(ptr %array, <4 x ptr> %baseptrs) {
%val = load <4 x i32>, ptr %array, align 4
%sextVal = sext <4 x i32> %val to <4 x i64>
%arrayidx = getelementptr inbounds [10000 x %"class.std::__1::complex"], <4 x ptr> %baseptrs, <4 x i64> zeroinitializer, <4 x i64> %sextVal
ret <4 x ptr> %arrayidx
}
```
https://github.com/llvm/llvm-project/pull/107848
More information about the llvm-commits
mailing list