[llvm] [InstCombine] Make foldCmpLoadFromIndexedGlobal more resiliant to non-array geps. (PR #150639)

Madhur Amilkanthwar via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 7 06:33:18 PDT 2025


madhur13490 wrote:

> > Hi @davemgreen Some tests are failing in one of our internal test suites. I have reduced the test to the IR: https://godbolt.org/z/a4W18rdsn
> > The phi node is getting replaced with a branch that eventually leads to an infinite loop. The test run faults with "Invalid Instruction" on Neoverse-V2 platform.
> > Can you please have a look and let me know if this can be fixed?
> 
> It looks like your code loads from an array that could be one of [97, 98, 99], then exits the loop if it is == 0. As that can never happen (without reading off the end of the array), it never exits the loops. I'm guessing the original had llvm.loop metadata that made infinite loops UB (it came from c++)? This sounds like standard C++ UB again if this is representative of the original.

Thanks, that makes sense. Yes, the code is indeed coming from C++.

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


More information about the llvm-commits mailing list