Add calculation for elements in structures in getting uniform base for the Gather/Scatter intrinsic.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4358 | I think for X86, we can leverage the displacement to handle indices aren't 0. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4369 | The normal way to do this is to use gep_type_iterator in the loop as well and increment it as you go through the loop. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4358 | Oh, displacement is already used for base. Sorry for the noise. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4369 | Great, thanks! |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4373 | Makes sence. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4373 | Maybe we can calculate the offset for struct if the index is constant. APInt Offset(DL.getIndexTypeSizeInBits(GEP->getType()), 0); if (!GEP->accumulateConstantOffset(DL, Offset)) return false; Index = DAG.getTargetConstant(Offset, SDB->getCurSDLoc(), TLI.getPointerTy(DL)); Scale = DAG.getTargetConstant(1, SDB->getCurSDLoc(), TLI.getPointerTy(DL)); Also recognize zeroinitializer in accumulateConstantOffset().
+++ b/llvm/lib/IR/Operator.cpp for (gep_type_iterator GTI = gep_type_begin(this), GTE = gep_type_end(this); GTI != GTE; ++GTI) { + ConstantInt *OpC = dyn_cast<ConstantInt>(GTI.getOperand()); if (!OpC) return false; |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4374 | Does the test cover this change? I was just pointing out a mistake in the FIXME. I wasn't trying to ask for a code change unless its relevant to fixing the bug the test is for. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4373 | Index inside a structure is always constant. Why we need recognize zeroinitializer? | |
4374 | Not currently. But there's a bit relationship. Without this change, I need to *make* the same constant somewhere to get the excepted result. %4 = icmp eq <8 x i32> %trigger, <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7> I think I can remove the constant to cover this change. I can also keep the FIXME. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4373 | Yes. I agree it is better to be implemented in another patch. <<<Why we need recognize zeroinitializer? |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4387 | just 'cast'? CI must be nonnull anyway, otherwise your assert fires. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4383 | Same here |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4387 | I wonder if there's a real case that index of a structure is not a constant? I guess not, but I'm not so sure. So I put an assert followed. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4387 | From LangRef "When indexing into a (optionally packed) structure, only i32 integer constants are allowed (when using a vector of indices they must all be the same i32 integer constant)." |
Removed unnecessary loop condition.
Added a vectorized index test.
Don't check if constant exist in DAG.
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4364 | Can we just handle the FinalIndex cases after the loop instead of trying to special case the last iteration of the loop? It might require a tiny bit of duplication, but I think it would be more understandable. |
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp | ||
---|---|---|
4364 | Sure! |
Hi,
I believe this commit broke the expensive checks bot. Could you take a look?
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-debian/builds/631
The previous build is green: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-debian/builds/630
I think for X86, we can leverage the displacement to handle indices aren't 0.