[all-commits] [llvm/llvm-project] 16a83c: [MLIR][LLVMIR] Restore constant folding for global...
Henrich Lauko via All-commits
all-commits at lists.llvm.org
Wed Sep 30 03:36:29 PDT 2026
Branch: refs/heads/users/xlauko/mlir-gep-initializer-fold
Home: https://github.com/llvm/llvm-project
Commit: 16a83c314f393bc412b4d1a4cee5c55c96d44e4e
https://github.com/llvm/llvm-project/commit/16a83c314f393bc412b4d1a4cee5c55c96d44e4e
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 c68a4ca2a920 (#226904), a GEP in a global initializer went through
`IRBuilder::CreateGEP`, and MLIR's `IRBuilder<TargetFolder>` ran the result
through `ConstantFoldConstant`. Besides combining nested GEPs and folding
null or integer bases, that infers `inbounds` when the offset stays within
the global's size and, since `inbounds` implies `nusw`, `nuw` for a
non-negative offset. #226904 builds the constant expression directly and
skips the folder, so those flags disappeared from the output.
Run `ConstantFoldConstant` on the built constant for the non-inrange case.
The inrange path bypassed the TargetFolder before as well and keeps its
output.
CIR's lit tests for vtables, VTTs and constant pointer initializers expect
the inferred `inbounds nuw` (for example CIR/CodeGen/vtt.cpp and
CIR/CodeGenCXX/base-layout.cpp) and have been failing 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