[llvm] [InstCombinePHI] Enable gep arg fold transform with constant indices (PR #174981)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 15 10:24:20 PST 2026


================
@@ -566,16 +567,24 @@ Instruction *InstCombinerImpl::foldPHIArgGEPIntoPHI(PHINode &PN) {
       AllBasePointersAreAllocas = false;
 
     // Compare the operand lists.
+    gep_type_iterator TypeIter = gep_type_begin(GEP);
     for (unsigned Op = 0, E = FirstInst->getNumOperands(); Op != E; ++Op) {
----------------
dtcxzyw wrote:

```suggestion
    for (unsigned Op = 0, E = FirstInst->getNumOperands(); Op != E; ++Op, ++TypeIter) {
```
Otherwise, it will be broken when the continue below is executed.


https://github.com/llvm/llvm-project/pull/174981


More information about the llvm-commits mailing list