[Vectorize] Declare command line options in TableGen (#231025)
TailFoldingPolicyTy moves to VectorizeOptions.h. LoopVectorize.h no
longer exports EnableLoopInterleaving and EnableLoopVectorization, which
nothing outside the library reads. LoopVectorizeHints and
LoopVectorizationLegality take the options struct in their constructors.
The -vplan-print-* options and -sbvec-always-verify are AssertsOnly
(#230898), no longer available in LLVM_ENABLE_DUMP builds without
assertions.
-vplan-verify-each defaults to VPlanVerifyEachDefault, true under
EXPENSIVE_CHECKS. -epilogue-vectorization-force-VF (ElementCount parser)
stays cl::opt.
Aided by Opus 5.5
[clang][ssaf] Interpose ld.lld in clang-ssaf-orchestrator-make (#231720)
A clang built with CLANG_DEFAULT_LINKER=lld, or given -fuse-ld=lld, runs
ld.lld for a link rather than ld, so the ld shim stands in for ld.lld
too. ld.lld takes ld's command line.
Assisted-by: Claude
[InstCombine] Fold fpto[su]i of llvm.trunc (#231414)
fptoui and fptosi already round toward zero, so a preceding llvm.trunc
is redundant and the conversion can take the untruncated value. NaN,
infinity, and out of range inputs produce poison in both forms.
```llvm
%t = call float @llvm.trunc.f32(float %x)
%r = fptosi float %t to i32
-->
%r = fptosi float %x to i32
```
The trunc may have other users; only the conversion operand is replaced.
Alive2 link: https://alive2.llvm.org/ce/z/HvbncV
[unittests] Skip target tests when the default triple is not built
PassBuilder and TargetMachine C API tests FAIL when LLVM_TARGETS_TO_BUILD
excludes the host triple. Skip instead, and avoid tearing down an
uninitialized TargetMachine after a skipped SetUp.
Co-authored-by: Cursor <cursoragent at cursor.com>
[libclc] Produce subnormal results for exp/exp2 on FP32 (#212696)
The FP32 __clc_exp/__clc_exp2 implementations scale the reduced result
by 2^p using integer bit manipulation (as_int(y) + (p << 23)). That
representation cannot encode a subnormal, so inputs whose result falls
below the smallest normal were unconditionally flushed to zero via "x <
llim ? 0.0f". On devices that report CL_FP_DENORM this loses the correct
subnormal result (e.g. erfc(), which is built on exp(), failed CTS
math_brute_force with the reference subnormal vs a returned 0).
Recompute the subnormal range with __clc_ldexp, which does produce
subnormals, gated on __clc_fp32_subnormals_supported() so flush-to-zero
targets keep the previous fast path. The ldexp path is restricted to
[subnorm_llim, llim); inputs below subnorm_llim (including -inf and
large-magnitude negatives) still flush to zero, since their reduced
exponent argument would be ill-formed for ldexp.
[flang][OpenMP] Fix cleanup placement of num_threads temporaries (#231659)
DISTRIBUTE PARALLEL DO and DISTRIBUTE PARALLEL DO SIMD evaluate the
PARALLEL clause operands before creating omp.parallel, using the
statement context of the dispatch. That context is finalized after the
returned omp.distribute, which is inside the parallel region, so every
thread destroyed the same num_threads temporary, for example for
num_threads(size(f())) where f returns an allocatable.
Evaluate these operands in a separate statement context and finalize it
after omp.parallel.
Fixes #230661
Assisted with Copilot and Claude Opus 5.5
[KnownFPClass] Add trunc/floor/ceil and fix ppcf128 demanded classes (#229982)
Adds `KnownFPClass` functions for `trunc`, `floor`, and `ceil`. Also
corrects the `DemandedSrcMask` code for `PPCDoubleDouble` in
`SimplifyDemandedUseFPClass` for the integer-rounding functions.
I've only added basic deductions for `PPCDoubleDouble` for now:
- `trunc(x)` is only `+-inf` if `x == +-inf` (we already had this)
- `floor(x)` is only `+inf` if `x == +inf`
- `ceil(x)` is only `-inf` if `x == -inf`
AI disclosure:
I used Claude Opus 5 to help write the code and tests.
[llvm-readobj][NFC] Move the 1-byte call graph info fields last
Group FormatVersionNumber and IsIndirectTarget at the end of
FunctionCallGraphInfo, after the 8-byte-aligned members.
Assisted-by: Gemini
[llvm-readobj] Test call graph callees below and above four
Add a function with fewer callees, as the old SmallSet already kept
section order for up to four, and say why main has five distinct
callees. Move main's repeated callee to the end, so that a repeat is
also skipped after the set of seen callees outgrows its inline size.
Assisted-by: Gemini
[SCEV] Prove monotonic predicates from loop entry in isKnownViaInduction
isKnownViaInduction requires the predicate to hold on loop entry and on
the backedge. The backedge check usually fails when the latch only
bounds the IV from above, so e.g. {s,+,1}<nsw> >=s 0 is not proven even
when s >=s 0 is known on entry.
In a loop guarded by "start <u len", this keeps IndVars from computing
a[i - 32] in i64.
A monotonically increasing predicate against a loop-invariant value can
only change from false to true, so holding on entry is enough.
Use this in isKnownOnEveryIteration when the backedge check fails.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[BPF] Use FETCH atomic instruction for monotonic atomicrmw when the result is used (#210371)
For BPF, a monotonic atomicrmw selected the non-fetch instruction
regardless of whether the result was used. The non-fetch form discards
the old value, so the result was wrong if used.
Fix makes ISel select the fetch form when the result is used and the
non-fetch form otherwise via the binop_no_use / binop_has_use PatFrags.
This was already done for the i64 and/or/xor patterns, applied it to the
remaining monotonic patterns: i64 add and sub, and all i32 ops
(add/sub/and/or/xor).
Fixes #210280
Assisted-by: Claude (Anthropic)
[SCEV] Prove monotonic predicates from loop entry in isKnownViaInduction
isKnownViaInduction requires the predicate to hold on loop entry and on
the backedge. The backedge check usually fails when the latch only
bounds the IV from above, so e.g. {s,+,1}<nsw> >=s 0 is not proven even
when s >=s 0 is known on entry.
In a loop guarded by "start <u len", this keeps IndVars from computing
a[i - 32] in i64.
A monotonically increasing predicate against a loop-invariant value can
only change from false to true, so holding on entry is enough.
Use this in isKnownOnEveryIteration when the backedge check fails.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[IndVarSimplify][PhaseOrdering][NFC] Add tests for widening nsw IV arithmetic
Add tests for for (int i = start; i < N; i++) a[i] = a[i - 32] + 1,
with zext nneg indices and i - 32 nsw only:
- IndVarSimplify: with guards that do and do not prove start
non-negative, i - 32 is computed in i64 or i32.
- PhaseOrdering (indvars, loop-vectorize): whether a runtime alias check
is emitted.
Move @runtime_start out of ult-nonneg-bound-implies-nonneg.ll, which
duplicated it.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[IndVarSimplify][NFC] Add a negative test for zext elimination
Add @foo3_neg: the loop from @foo3 with a guard on an unrelated value,
so %add3 may be negative and its zext must stay.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV][NFC] Use isKnownOnEveryIteration in isKnownViaInduction
isKnownViaInduction and isKnownOnEveryIteration both prove a predicate
on every iteration from loop entry and the backedge, so the next change
can extend one place.
Add a private isKnownOnEveryIteration overload that takes any LHS and
RHS and the loop, and move the entry/backedge check from
isKnownViaInduction into it. The public overload is unchanged.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV][NFC] Factor getMonotonicPredicate out of getLoopInvariantPredicate
The next change needs the same setup as getLoopInvariantPredicate.
Move it into a private helper: put the loop-invariant operand on the
RHS, check that the other side is a recurrence of the loop, and compute
the predicate's monotonicity.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>