[MLIR][arith] Fold or(a, or(a, b)) to or(a, b) (#228386)
`arith.andi` already folds `and(a, and(a, b))` to `and(a, b)`, but
`arith.ori` doesn't perform the equivalent fold, so using canonicalize
misses this opportunity.
Generalize the existing helper and use it for both ops.
Co-authored-by: Matthias Springer <me at m-sp.org>
[gn] port 82290a03b3cc a bit (CASPluginTest) (#228639)
Also disable llvm_enable_ondisk_cas for a bit until I can figure out how
to fix
dlopen(..../out/gn/lib/CASPluginTest.dylib, 0x0009):
symbol not found in flat namespace '__ZN4llvm4SHA15finalEv'
when running llvm/test/tools/llvm-cas lit tests. (The unit test passes.)
[flang] Add a MLIRToLLVMPassPipeline callbacks for plugins (#212195)
Expose the extension points of the HLFIR-to-FIR pass pipeline exposes extension points to plugins.
Follow-up to #212194
Assisted-by: Claude Code (Opus 5, Opus 5.5)
[InstCombine] Fold select of pow into select of the differing operand
When both arms of a select are calls to `llvm.pow` with one use that
differ in exactly one operand, sink the select into that operand:
$$
\mathrm{select}(c,\ x^{y},\ x^{z}) \rightarrow x^{\mathrm{select}(c,\ y,\ z)}
$$
$$
\mathrm{select}(c,\ x^{z},\ y^{z}) \rightarrow \mathrm{select}(c,\ x,\ y)^{z}
$$
This removes one `pow` call. FMF are intersected and debug locations
are merged. The transform is skipped when a differing operand is a
constant, since that may enable a cheaper lowering (e.g.
$x^2 \rightarrow x \cdot x$).
[InstCombine] Add tests for select of pow with one differing operand
Add tests for select between two `llvm.pow` calls whose operands differ in
exactly one position, covering scalar and vector types, FMF, !prof
metadata, constant operands, and negative cases (multiple differing
operands, extra uses, mismatched intrinsics).
[NFC][TSan] Make Context::nreported atomic (#228602)
Make Context::nreported an atomic_uint32_t so that Finalize and
__tsan_report_count can read it without relying on report_mtx.
Assisted-by: Gemini
[mlir] Set WrapNamespaceBodyWithEmptyLines: Never (#221421)
MLIR predominantly writes namespace bodies without a wrapping empty
line: in mlir/lib and mlir/include 35% of bodies start with an empty
line and 32% end with one.
```
namespace ns { // no empty line below
struct A {
};
} // namespace ns // no empty live above
```
New code drifts the other way, partly related to LLM preference. Pin the
majority style using a clang-format 20 feature to stop further damage.
[flang] Add a pass-pipeline config callback hook for plugins
The HLFIR-to-FIR pipeline extension points live on MLIRToLLVMPassPipelineConfig,
which the frontend builds as a local of CodeGenAction, out of reach of a plugin.
Add a process-global registry of callbacks that run on the config before the
pipeline is built. A plugin registers one from a static initializer, so it is in
place before any compilation begins, as FrontendPluginRegistry does for plugin
actions. Both code generation entry points invoke the callbacks, lowerHLFIRToFIR
for -emit-fir and generateLLVMIR for -emit-llvm/-emit-obj, and are mutually
exclusive for a given compilation, so a plugin sees the same behaviour whichever
output was asked for.
Co-Authored-By: Claude Opus 5 <noreply at anthropic.com>
[flang] Address review comments on the pipeline config callbacks
- Adopt the suggested doc comment wording and name the callback type
(PassPipelineConfigCallback) instead of spelling std::function / auto.
- Run the callbacks in generateLLVMIR once the config is fully set up, so a
plugin sees the OpenMP/OpenACC, vscale and other settings as on -emit-fir.
- Document that -emit-fir only reaches the HLFIR extension points, that
callbacks must not register callbacks, and that bbc/tco/fir-opt do not run
the registry.
- Tests: drop the redundant epRan flag and use a plain global recorder.
Assisted-by: Claude Code (Opus 5.5)