[clang] [llvm] [ConstantFold] Remove non-trivial gep-of-gep fold (PR #93823)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu May 30 07:18:22 PDT 2024


nikic wrote:

> > because the DL-aware constant folding will take care of this anyway.
> 
> Can you point out where we do this fold?

https://github.com/llvm/llvm-project/blob/1f46729a18ef13c3ba4184ead1da4ab3037cb7ae/llvm/lib/Analysis/ConstantFolding.cpp#L865

> > I've only kept the straightforward zero-index case, where we just concatenate two GEPs.
> 
> Is there a test for this case?

It looks like we don't have an LLVM test, but it affects a few clang tests:
```
  Clang :: CodeGenCUDA/managed-var.cu
  Clang :: CodeGenCXX/2011-12-19-init-list-ctor.cpp
  Clang :: CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
  Clang :: CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
  Clang :: CodeGenCXX/ms-inline-asm-fields.cpp
  Clang :: OpenMP/threadprivate_codegen.cpp
```
I kind of expected more clang fallout, so I'd be open to just dropping this fold from the DL-unaware folder completely, even the basic case.

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


More information about the llvm-commits mailing list