[InstCombine] Fold consecutive udivs into a single udiv (#214541)
Extend the existing `(X / C1) / C2 -> X / (C1 * C2)` fold to variable
divisors:
(X udiv Y) udiv Z -> X udiv (Y * Z) if Y * Z does not overflow
Uses willNotOverflowUnsignedMul to prove the product doesn't wrap.
Instruction count is unchanged but a division becomes a multiplication,
similar to the existing cttz-based udiv->lshr fold in visitUDiv.
One-use on the inner div, since otherwise we'd add a mul without
removing
the div. exact only propagates when both divides are exact.
Alive2: https://alive2.llvm.org/ce/z/qV6UJH
Fixes #132908
[mlir][arith][NFC] Make AtomicRMWKind switches exhaustive (#214622)
`getIdentityValueAttr` and `getReductionOp` in `ArithOps.cpp` each
handle 15 of
the 16 `AtomicRMWKind` cases and route the rest through a `default:`
label
carrying `// TODO: Add remaining reduction operations.`
That TODO cannot be completed. The only unhandled kind is `assign`,
which is
not a reduction: it has no identity element (`assign(x, e) = e`, so no
constant
`e` satisfies `assign(x, e) = x`) and no corresponding binary `arith`
op. It is
still a perfectly valid kind elsewhere — `memref.atomic_rmw` lowers it
to an
atomic `xchg` in `MemRefToLLVM.cpp` — it simply has no meaning for these
two
reduction helpers.
[39 lines not shown]
[VPlan] Verify hoist point when hoisting previous value of a recurrence. (#215084)
tryToSinkOrHoistRecurrenceUsers processes the fixed-order recurrences of
a loop one at a time and updates the plan for each of them. Once the
plan has been updated for one recurrence, the properties
hoistPreviousBeforeFORUsers relies on may no longer hold for the
recurrences processed later
Convert dominance assertion that does not hold in all cases (added test
cases) to a bail out, to a crash on the added test.
PR: https://github.com/llvm/llvm-project/pull/215084
[ORC] Remove CallableTraitsHelper (#215089)
CallableTraitsHelper was only used by CallViaEPC.h / CallSPSViaEPC.h,
which were removed in the previous commit. With those gone it has no
remaining users, so remove it and its unit test.
[SLP]Charge spill cost for loop-invariant gathers live over a call
Loop-invariant gathers hoisted to the preheader by
optimizeGatherSequence are live across calls in the loop body and need
spill/reload on targets with call-clobbered vector registers, but were
skipped by getSpillCost. Charge them like other call-crossing values.
Fixes #214555
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/215093
RuntimeLibcalls: Fix reporting incorrectly typed fp128 long double functions
l-suffixed long double math functions are fp128 only when the target's
long double is fp128. The default set provided them on every target that was
not x87 or ppc_fp128, so targets using double as long double wrongly reported
the fp128 l-suffixed functions.
Update tests that were reliant on phantom fp128 calls. These are only available
with glibc on select targets. In cases where the target supports the calls in
some triple, split the tests. In cases where the target has no fp128 library
support, delete the tests.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[ORC] Remove CallViaEPC.h and CallSPSViaEPC.h (#215086)
These provided EPC calls with pluggable serialization (EPCCaller /
EPCCall / SPSEPCCaller / SPSEPCCall). That role is now filled by the
RTBridge Proxy APIs (rt::Proxy + rt::sps::ProxySpec), and these headers
had no users other than their own unit test, so remove them along with
CallSPSViaEPCTest.
DAG: Gracefully diagnose missing soft-float and strict-FP libcalls
Several soft-float legalization paths legalizer, called into a libcall
without checking whether the target provides one, fatally erroring for
fp128 operations on targets with no soft-float support.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
DAG: Gracefully diagnose missing lrint/llrint/lround/llround libcall
Avoid hitting the fatal error in makeLibCall by emitting a diagnostic
if the library call is unsupported.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[ORC] Rename RTBridge Caller to Proxy (#215077)
Mechanical rename of the controller-side call handle, with no functional
change:
- rt::Caller<Sig> -> rt::Proxy<Sig> (and CallerBase / CallerInit /
callerInit / buildCallers -> Proxy*), RTBridge/Calls.h ->
RTBridge/Proxy.h.
- rt::sps::CallerSpec -> rt::sps::ProxySpec, RTBridge/SPS/Calls.h ->
RTBridge/SPS/ProxySpecs.h.
- The named proxies for function-calling wrappers gain a Call verb
(CallMainProxy, CallInt32Int32Proxy, ...), matching the
orc_rt_ci_sps_call_* wrappers they target.
This frees "caller" for the executor-side concept: a runtime function
that calls another function.
Also split the unit test along the same seam: ProxyTest.cpp covers
generic, protocol-agnostic rt::Proxy behavior via an in-process dispatch
(no serialization), and SPSProxiesTest.cpp covers the SPS proxies'
serialization round-trips.
[VPlan] Add tests for outer-loop accesses with irregular types (NFC). (#215075)
Add coverage for stride-1 outer-loop accesses of element types that are
bit-packed in vectors (i1, i4).
While touching the file, remove some unnecessary checks.
[SPARC] Fix %hi/%lo of absolute expressions in PIC mode (#215066)
adjustPICRelocation maps %hi/%lo to GOT22/PC22 or GOT10/PC10 at parse
time, before the operand is known to be absolute. adjustFixupValue has
no case for the GOT types, so an absolute operand encodes the unshifted
value:
Encode %got22/%got10 like %hi/%lo. Also drop them as input syntax; GNU
as has no such operators.
DAG: Gracefully diagnose missing soft-float and strict-FP libcalls
Several soft-float legalization paths legalizer, called into a libcall
without checking whether the target provides one, fatally erroring for
fp128 operations on targets with no soft-float support.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[GlobalISel] Add G_ROTL/G_ROTR to computeNumSignBits (#213364)
Port SelectionDAG's `ROTL`/`ROTR` handling to
`GISelValueTracking::computeNumSignBits`.
Addresses one of the subtasks of #150515.
---
Assisted by Claude (Anthropic).
[CIR][AMDGPU] Add support for AMDGCN permlane builtins (#197526)
Adds codegen for the following AMDGCN permlane builtins:
- __builtin_amdgcn_permlane16
- __builtin_amdgcn_permlane64
- __builtin_amdgcn_permlanex16
These are lowered to the corresponding `llvm.amdgcn.permlane16`,
`llvm.amdgcn.permlanex16`, and `llvm.amdgcn.permlane64` intrinsics.
DAG: Gracefully diagnose missing soft-float and strict-FP libcalls
Several soft-float legalization paths legalizer, called into a libcall
without checking whether the target provides one, fatally erroring for
fp128 operations on targets with no soft-float support.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[flang] Reject module-scope fir.alloca (#214157)
`fir.alloca` represents a stack allocation, but its verifier currently
accepts operations placed directly in a `builtin.module`. During
FIR-to-LLVM conversion, `AllocaOpConversion::matchAndRewrite` calls
`getBlockForAllocaInsert`, which performs a `dyn_cast` to
`OutlineableOpenMPOpInterface` on the alloca's parent op.
For a module-level alloca the expected parent function/block does not
exist and the cast/assert fails.
This patch rejectsdirect module-scope `fir.alloca` operations during FIR
verification.
Assisted-by: codex
---------
Signed-off-by: Keshav Vinayak Jha <keshavvinayakjha at gmail.com>
[Flang] Coarray allocation, update error for pointer component #193829 (#194651)
The TODO message in `verify()` was not completly displayed, so it has
been replaced by `emitErrorOp`.
In addition, the test in `ConvertVariable` has been updated by adding
pointer direct component case.
Fix #193829
(cherry picked from commit 9adc2537177d0813301b3eab1bae906735c984a4)