[libc][math] Optimize exp and share double-precision evaluation with exp2.
Refactor double-precision exp to share most of the computations with exp2,
and adding support for `LIBC_MATH_HAS_SMALL_TABLES` and
`LIBC_MATH_HAS_SKIP_ACCURATE_PATH.
Assisted by: Gemini is used for performance and code size analysis and refactoring.
cc1as: Parse library options into a context. NFC (#233017)
Follow-up to #231407: move tools off cl::ParseCommandLineOptions, which
sets the libraries' `XXXOptions::Global`, to
`cl::parseCommandLineOptions(LibraryOptionsContext &, ...)`.
This prepares for removing the T::Global fallback in
`LibraryOptionsContext::get<T>()`.
Parse library options into a context. NFC (#233013)
Follow-up to #231407: move tools off cl::ParseCommandLineOptions, which
sets the libraries' `XXXOptions::Global`, to
`cl::parseCommandLineOptions(LibraryOptionsContext &, ...)`.
This prepares for removing the T::Global fallback in
`LibraryOptionsContext::get<T>()`.
Parse library options into a context in more tools. NFC
Follow-up to #231407: move tools off cl::ParseCommandLineOptions, which
sets the libraries' `XXXOptions::Global`, to
`cl::parseCommandLineOptions(LibraryOptionsContext &, ...)`.
This prepares for removing the T::Global fallback in
`LibraryOptionsContext::get<T>()`.
Parse library options into a context in more tools. NFC (#233016)
Follow-up to #231407: move tools off cl::ParseCommandLineOptions, which
sets the libraries' `XXXOptions::Global`, to
`cl::parseCommandLineOptions(LibraryOptionsContext &, ...)`.
This prepares for removing the T::Global fallback in
`LibraryOptionsContext::get<T>()`.
[libc++] Properly pass the LNT submission token to the submit workflow (#233010)
Reusable worklows don't automatically get their environment secrets
passed, they need to declare them and their callers to pass them
explicitly.
[SLP] Handle REVEC when costing expanded compress mask
With REVEC the scalars are vectors. The masked-load-compress shuffle that is
emitted uses the compress mask expanded to the elements of those vectors
(transformScalarShuffleIndiciesToVector), but the cost was computed with the
unexpanded per-vector mask, so a shuffle such as <24 x i8> -> <16 x i8> was
costed as a <2 x i8> shuffle. This made the compress sequence looked cheaper
than it is.
Assisted-By: Claude Sonnet 5.5
[mlir] Check greedy rewrite fingerprints and changed flag (#232576)
Under EXPENSIVE_CHECKS, compare operation fingerprints before and after
greedy rewriting. If the IR changes but the driver reports no change,
emit a fatal error.
Assisted-by: gpt 6.1 sol
[InstCombine] Canonicalize atomicrmw sub of a constant to add
Rewrite `atomicrmw sub ptr, C` as `atomicrmw add ptr, -C`. This
matches the canonical form InstCombine already uses for plain `sub`.
In wrapping arithmetic $old - C = old + (-C)$, so both the stored
value and the returned old value stay the same, including when C is
`INT_MIN`. Ordering, syncscope and metadata are kept.
```llvm
; before
%old = atomicrmw sub ptr %p, i32 1 syncscope("agent") monotonic
; after
%old = atomicrmw add ptr %p, i32 -1 syncscope("agent") monotonic
```
This benefits AMDGPU, for example: https://godbolt.org/z/39xsYro3o
[CIR] Skip record rebuilds for unchanging types in CXXABI lowering (#232880)
CIRABITypeConverter only rewrites data-member and method types, but it
did not override typeMayChange, so every named record converted to a
renamed copy and every op touching one was illegal, forcing the generic
pattern to rebuild them all. Override it to report only those two types
as possibly changing, letting records that reach neither convert to
themselves and stay legal.
Small gains across the more expensive selfhosting TUs (no CIR output
changes):
- Registry 36.7->35.8,
- ASTImporterTest 64.4->63.7,
- SLPVectorizer 93.6->91.9,
- OpenMPDecomp 39.5->38.1,
- SemaExpr 59.3->57.5.
[flang][OpenMP] Don't drop NOTHING with clauses in METADIRECTIVE
A METADIRECTIVE replacement of NOTHING was treated as having no
directive, even when it had clauses. A selected `nothing apply(...)` was
therefore lowered as a no-op, silently dropping the loop transformation.
Keep NOTHING as a replacement when it has clauses, and report it as not
yet implemented in lowering.
Assisted-by: GitHub Copilot (Claude Opus 5.5)
[TableGen] Mark Macro Fusion Features as Inline Ignore (#232889)
Tuning features are conventionally inline ignore -- you tune the whole
function according to the caller rather than merging caller/callee
tuning features.
Macro Fusion features are a kind of tuning feature, and until now were
marked InlineDefault - with this change they should be ignored and
therefore not prevent inlining.
Assisted-by: AI (for Tests)
[InstCombine] Add tests for atomicrmw sub of a constant. NFC
atomicrmw sub C can be canonicalized to atomicrmw add -C because both
produce the same stored and returned values under wrapping arithmetic.
Cover syncscope, INT_MIN, and negative cases.
[LoongArch] Extract FP vector element 0 as a subregister
Element 0 of an LSX/LASX floating-point vector is the aliased FPR, so
extractelement with index 0 needs no [x]vreplvei/xvpickve.
[flang] Set the target in bbc's semantics context
bbc created a target machine but never passed its triple and features to
the semantics context. Without a target triple, semantics treats device
and implementation context selectors as possibly matching, so it
checked METADIRECTIVE replacements that can never be selected for the
target. For example, bbc reported a COLLAPSE error for the SIMD
replacement of when(device={arch(nvptx64)}: simd collapse(2)) on
x86-64, while flang accepts it.
Set the semantics target triple and features from the target machine, as
the flang driver does.
Assisted-by: GitHub Copilot (Claude Opus 5.5)
[Option] Make Passes, Scalar, Instrumentation, and CGData options per-context (#232599)
Follow-up to #232365: drop `perContext = false` from PassesOptions,
ScalarOptions, InstrumentationOptions, and CGDataOptions.
* IR passes read their LLVMContext's options in run(). Legacy passes
that chose analyses from an option now always require them
(ConstantHoisting, StructurizeCFG, GVN).
* Pass parameters that an option overrides are combined in run(), so
-print-pipeline-passes no longer folds such options (e.g.
-bonus-inst-threshold) into the printed parameters.
* PipelineTuningOptions carries the library options to PassBuilder,
which falls back to the TargetMachine's. opt, clang, flang, and Polly
pass their module's.
* The CodeGenData singleton is configured by its first caller's context.
lld and llvm-cgdata pass an empty context, which reads the global
values their -mllvm sets.
LLM-aided
[flang][OpenMP] Match variant selectors in the source construct context
The construct context for METADIRECTIVE and DECLARE VARIANT came from
enclosing MLIR operations. It recognized only a few operations, followed
operation nesting instead of source nesting, kept constructs outside an
enclosing TARGET, and used the body context for clause expressions and
loop bounds.
Build the context from the evaluation's source ancestors and from frames
for construct regions entered during lowering:
- A selected METADIRECTIVE replacement stands in for its source construct.
- TARGET discards the outer context.
- Constructs without a selector property still add a nesting level.
- Clause expressions see only enclosing constructs.
- Loop bounds see the leaves that precede the first loop-associated leaf.
- Specification expressions see no construct.
Add llvm::omp::getConstructTraits, which returns the construct traits a
directive adds in source order, with an invalid placeholder for a
[14 lines not shown]
[CIR][Docs][www] Generate and publish the CIR dialect reference docs (#232912)
Wire up a consolidated CIR dialect reference page: the existing
-gen-dialect-doc output (operations, types, attributes, enums) plus a
passes section generated from Passes.td (-gen-pass-doc), merged ahead of
the other sections with an explicit index of the page sections.
The landing page grows a "CIR Dialect Reference" section right after
"Using ClangIR", showing an index into the reference page.
Also fix the doc tablegen include roots: the `MLIR_*_INCLUDE_DIR`
variables are still empty when Clang configures (MLIR configures later),
so derive the same roots from LLVM dirs instead; without this the
tablegen cannot find `mlir/*.td`.