[all-commits] [llvm/llvm-project] 0aa508: [MLIR][LLVMIR] Restore constant folding for global...

Henrich Lauko via All-commits all-commits at lists.llvm.org
Wed Sep 30 04:34:06 PDT 2026


  Branch: refs/heads/users/xlauko/mlir-gep-initializer-fold
  Home:   https://github.com/llvm/llvm-project
  Commit: 0aa508380bc302a50e954e2339d661d02b674973
      https://github.com/llvm/llvm-project/commit/0aa508380bc302a50e954e2339d661d02b674973
  Author: Henrich Lauko <hlauko at nvidia.com>
  Date:   2026-09-30 (Wed, 30 Sep 2026)

  Changed paths:
    M mlir/lib/Target/LLVMIR/Dialect/LLVMIR/CMakeLists.txt
    M mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp
    M mlir/test/Target/LLVMIR/llvmir.mlir

  Log Message:
  -----------
  [MLIR][LLVMIR] Restore constant folding for global initializer GEPs

Before #226904, a GEP in a global initializer went through
IRBuilder::CreateGEP, and MLIR's IRBuilder<TargetFolder> folded the result
with ConstantFoldConstant. That combines nested GEPs, folds null and integer
bases, and infers inbounds and nuw when the offset stays within the global.
Building the constant expression directly skipped the folder, so the output
lost those flags.

Fold the constant again. This also applies to inrange GEPs, which used to
bypass the folder; the only visible difference there is that an inbounds
GEP with a non-negative offset now also gets nuw.

CIR's vtable, VTT and constant pointer tests check for the inferred flags
(for example CIR/CodeGen/vtt.cpp) and have failed since #226904.

Assisted-by: Claude Code (Claude Fable 5.1).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list