[SCEV][IndVars][NFC] Add tests for x >=s 0 from x <u y and y <=u 2^(n-1)
Let n be the bit width of x and y. If x <u y and y <=u 2^(n-1), then
x >=s 0. SCEV can't prove this yet.
Add tests for it.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV] Derive x >=s 0 from x <u y and y <=u 2^(n-1)
Let n be the bit width of x and y. If x <u y and y <=u 2^(n-1), then
x <u 2^(n-1), so x >=s 0. Here y <=u 2^(n-1) means y >=s 0 or
y == INT_MIN. In the same way, if x <=u y and y <u 2^(n-1), then
x >=s 0.
This lets a guard like x <u len prove x >=s 0 when len is non-negative.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV][IndVars][NFC] Add tests for x >=s 0 from x <u y with swapped operands
Let n be the bit width of x and y. If x <u y and y <=u 2^(n-1), then
x >=s 0. SCEV can't prove this yet when the operands of the compare to
prove are in the opposite order to the guard, e.g. 0 <=s x with
x <u y known.
Add tests for it.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV] Prove signed/unsigned implications in either operand order
SCEV could prove these implications only with the operands in the same
order:
- If a <u b and a, b have the same sign, then a <s b.
- If a <s b and a, b have the same sign, then a <u b.
- If a <u b and b >=s 0, then a <s b.
- If a <s b and b <s 0, then a <u b.
For example, it proved a <s b from a <u b and b >=s 0, but not b >s a.
Now it proves them in either order.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV] Try other implications when sign-flipped ones fail
SCEV's isImpliedCondBalancedTypes tries to prove an implication
through several rules. There are rules for when a predicate to prove
is sign-flipped from the found predicate, and also there are other
rules, which, for example, try to prove the implication through
ranges.
Before, if a proof for a sign-flipped rule implication returned false,
we wouldn't check other rules and just bail out with false result too.
Now make those rules fall-through - if one rule couldn't be proven,
try other rules in the function.
An example query is x - 5 <s 5 with x <u 10 known.
The implication "a <u b and b >=s 0 --> a <s b" matches it,
but x - 5 <u 5 with x <u 10 known does not hold (e.g. x = 0),
so SCEV gave up.
[5 lines not shown]
[SCEV][IndVars][NFC] Add tests for implied conditions with different signedness
SCEV can prove some signed conditions from unsigned ones and the other
way around. For example, it proves a <s b from a <u b and b >=s 0. But
it fails when the operands are in the opposite order, like b >s a.
Add tests for this.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV][NFC] Factor isImpliedCondViaSignFlippedPred out of isImpliedCondBalancedTypes
Move the code that proves a condition from a found condition with the
other signedness into a new private function.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[SCEV][IndVars][NFC] Add a test for signed conditions implied by unsigned bounds
SCEV can't prove some signed conditions that hold because of an
unsigned bound on the same value. For example, if x <u 10, then
0 <= x < 10, so x - 5 <s 5.
Add a test for it.
Co-Authored-By: Claude Opus 5.5 <noreply at anthropic.com>
[BPF] Simplify CO-RE relocation dispatch (NFC) (#234250)
Group relocation kinds and instruction opcodes by their common
discriminator. Return enum access details explicitly and derive the
result width from the intrinsic type, preparing for changes to
relocation payload handling.
Assisted-by: OpenAI Codex
[libc][math] Short-circuit certain powf range errors (#223719)
## Summary
Replace the earlier monolithic powf optimization with a narrowly scoped
subnormal-base shortcut on top of the redesigned implementation from
#226588. The existing shared exceptional handler already covers extreme
exponents, so the old large-exponent shortcut is not retained.
For a nonzero subnormal base, its normalization shift proves
`abs(x) < 2^(-125-shift)`. For positive y, `y*(125+shift) >= 150` proves
the magnitude of the result is strictly below `2^-150`. Return through
the existing signed underflow helper, after special-input/domain/parity
handling. Use an exact double product where hardware double is available
and an exact unsigned integer comparison otherwise.
Add smoke coverage for both evaluators and the default entry point,
including directed rounding, negative odd-integer results, the
half-minimum-
[80 lines not shown]
[flang][OpenACC] Recover from repeated and conflicting loop modes (#234430)
Flang currently rejects repeated `seq` or `independent` clauses, and
directives containing both modes. Accept these cases as a documented
OpenACC compatibility extension on standalone and combined loop
directives, with one `-Wopenacc-usage` warning per affected directive.
Repeated clauses of one mode retain a single copy. If both modes occur,
remove all occurrences of both clauses before structure checking and
lowering, so the loop uses the same default mode as a directive with
neither clause. This avoids accidentally retaining an `independent`
promise after diagnosing a conflict. Directives containing `auto` or
`device_type` keep their existing diagnostics.
Warnings remain enabled for executable source in separately compiled
submodules, including when an ancestor scope was imported from a module
file. The extension honors `-Werror`, `-w`, and `-Wno-openacc-usage`.
The tests cover repeated and mixed modes on standalone and combined
[3 lines not shown]
[VPlan] Expand AddRecs in VPlan, only canonical ARs in IR. (#230858)
Expand AddRecs of loops outside VPlan's scope in VPSCEVExpander
mirroring SCEVExpander::visitAddRecExpr:
* {X,+,F} is expanded as X + {0,+,F} (using ptradd for pointers)
* {0,+,F} as {0,+,1} * F.
* narrow canonical are expanded by truncating a wide canonical IV, if
one exits.
Only canonical IVs (and non-affine AddRecs) are expanded by IR
SCEVExpander (as VPExpandSCEVRecipe), which re-uses or creates new
instructions outside VPlan's scope (in the loop that contains the
AddRec).
PR: https://github.com/llvm/llvm-project/pull/230858
[Support] Added file_size(file_t) to improve performance on Windows (#234610)
Usually sys::fs::file_status is using to get the file size. But Windows
implementation of sys::fs::status(file_t, file_status &) is very slow
especially because of calling realPathFromHandle(). Added
sys::fs::file_size(file_t) which uses system's GetFileSizeEx().
NFC for non-Windows systems.
[lldb-dap][test] Read until the EOF from the adapter (#234587)
The read loop previously stops if the transport is no longer alive. This
is true when either the client or the adapter disconnects. The adapter
can send disconnect and immediately close the connection giving the
client little to no time
to read the data.
The read loop now reads until EOF from the adapter, to read any missing
data in the reader's buffer.
Update the test to simulate this.
Fixes
https://github.com/llvm/llvm-project/issues/137660#issuecomment-5635649521
[CIR] Do not assume function aliases are dso_local under PIC
For PIC code that is not a PIE, shouldAssumeDSOLocal marks a function
dso_local when it can use a local alias, as classic codegen does.
Classic applies that only to real functions, never to aliases. CIR
represents a function alias as a FuncOp with an aliasee, so the check
now skips aliases. The flag does not reach LLVM IR yet, because MLIR's
translation drops dso_local on aliases. #234012 fixes that.
Assisted-by: Cursor / claude-opus-5.5
[GlobalOpt] Only remove atexit calls where atexit is the callee (#234731)
Calls that only pass __cxa_atexit or atexit as an argument were wrongly
removed.
Fixes #234325
[flang][cuda] Sync the device descriptor of a global passed to a POINTER or ALLOCATABLE dummy (#234679)
A module or SAVE'd pointer or allocatable with a CUDA data attribute has
a device copy of its descriptor. Lowering keeps that copy up to date
with `cuf.sync_descriptor` after pointer assignment, ALLOCATE and
DEALLOCATE, but only when the statement itself names the global. When
the association or allocation happens inside a callee through a POINTER
or ALLOCATABLE dummy argument, the callee updates the host descriptor
and nothing syncs the device copy, so a later kernel reads a null
descriptor and faults.
Emit `cuf.sync_descriptor` after a call for every actual argument that
is a registered device global passed to a POINTER or ALLOCATABLE dummy
that is not `intent(in)`. Kernel launches and device code are skipped.
`genPointerSync` now takes the statement location so the sync is
attributed to the call rather than to the declaration.
[WholeProgramDevirt] don't let a dead vtable prevent devirtualization (#232432)
When a vtable is dead and local, it should not prevent devirtualization.
https://godbolt.org/z/qxcM1ab5j
This currently does not devirtualize the call in `call1` even though
there is only one live member of the `!0` set:
```llvm
define void @call1(ptr %obj) {
%vtable = load ptr, ptr %obj, align 8
%1 = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid1")
%2 = getelementptr i8, ptr %vtable, i32 0
%3 = load ptr, ptr %2, align 8
call void %3(ptr %obj)
ret void
}
```
[11 lines not shown]
[AMDGPU] Materialize subregister WMMA scales at lane width
Copy an SGPR subregister scale into a VGPR of that lane's size so two
lanes of one tuple stay independent.
Co-authored-by: Cursor <cursoragent at cursor.com>
[lldb] Replace lldb_setup_rpaths with lldb_add_rpaths (#233996)
There is a way to add rpaths instead of wholesale replacement. It is far
less dangerous to append duplicate RPATHS than to replace them entirely.
[Fuchsia] Disable CIR in Fuchsia's toolchain builds (#234242)
CIR is adding significant build time and additional breakages w/o any
benefit, so remove it from our cache files.