[VPlan] Only treat recipes as ephemeral if all defined values are. (#249290)
Only treat a recipe as ephemeral if all its defined values are only used
by ephemeral recipes. This fixes register usage computation and the
check whether a plan generates vectors for interleave groups with a
member only used by an assume.
[CodeGen] Remove unused members in MIRAddFSDiscriminatorsLegacy (NFC) (#249270)
This patch removes getMachineFunction and MF from
MIRAddFSDiscriminatorsLegacy. getMachineFunction has no callers, and
MF has no writers.
Assisted-by: Antigravity
[X86] Compute `CTLZ` using fp math for `v4i32` on SSE2 targets (#190930)
This PR implements optimization for the `ISD::CTLZ` and
`ISD::CTLZ_ZERO_POISON` for X86 SSE2 target.
This PR builds upon #167034
Closes #161746
Co-authored-by: NishiB137 <cs23btech11041 at iith.ac.in>
Co-authored-by: VindhyaP312 <cs23btech11044 at iith.ac.in>
Co-authored-by: Simon Pilgrim <llvm-dev at redking.me.uk>
[SampleProfile] Recover hot contexts rejected by indirect-call promotion (#243628)
A sample profile can record samples for an indirect-call target under
its caller, as if the compiler had inlined the target. If the compiler
leaves the target out of line, those samples belong in the target's
standalone profile. Leaving them under the caller makes the standalone
function appear colder than it is.
This patch recovers those samples in both sample-profile inliners:
- Priority inliner: A target can be hot in absolute terms but account
for too few calls at a site to qualify for promotion. Previously, the
loader stopped at the first target that failed the percentage check. It
now records that target and continues through the remaining hot targets.
It stops when the targets are no longer hot. Several rejected targets at
the same call can therefore recover their samples.
- Iterative inliner (line-based AutoFDO): When the compiler promotes and
inlines one target, an indirect fallback remains for the other targets.
A later scan can mistake the already-inlined target for one that still
needs recovery. Tracking only one target per call can also miss other
[19 lines not shown]
[Passes] Declare -enable-profcheck-in-pipeline and -use-ctx-profile in TableGen (#249267)
Move them into IROptions and AnalysisOptions with exported getters.
CtxProfAnalysis reads -use-ctx-profile in run() instead of its
constructor.
Renames, with the old spellings kept as aliases:
```
-enable-profcheck-in-pipeline -> -profcheck-in-pipeline
```
Co-authored-by: Alexis Engelke <mail at aengelke.net>
[RISCV] Replace some uses of SplatFPOp with a ComplexPattern. NFC (#249166)
SplatFPOp is a PatFrag that checks 2 different opcodes. Every time it is
used we create 2 isel patterns. Since all those patterns handle multiple
element types and LMULs, this quickly adds up.
Replace it with a ComplexPattern like we do for integer. This reduces
the isel table size by 9.3%.
Assisted-by: Claude
[AArch64]Duplicate the repeated lower half of 128-bit build vectors
A 128-bit build vector whose upper half repeats the lower half, e.g.
(a, b, a, b), was lowered with one lane insert per element. Build the
lower half once and concatenate it with itself. Undef upper lanes match
anything; an all-undef upper half is left to the insert sequence, where
it needs no copy.
Assisted-by: Cursor
Pull-request: https://github.com/llvm/llvm-project/pull/247230
Reviewers: davemgreen, huntergr-arm, john-brawn-arm, paulwalker-arm, sdesmalen-arm
Reviewed-by: sdesmalen-arm
[mlir][OpenACC] Fix assertion macro expansion (#248975)
ACC_COMPUTE_CONSTRUCT_AND_LOOP_OPS expands to a comma-separated type
list. On systems where assert forwards its expression to another macro,
the commas are parsed as separate macro arguments.
Wrap the isa expression in an extra parenthesized group so it is passed
as one macro argument.
[DAG] Treat truncating an extend back to its source type as free (#249269)
I changed TargetLowering::isTruncateFree(SDValue, EVT) to treat
truncating a sign/zero/any extend back to its source type as free, since
the truncate just gives back the extend's operand. This is split out of
#236194 as requested there. That PR uses it to decide whether narrowing
uitofp vXi64 is worth it with AVX512DQ.
On its own, this lets the generic uitofp narrowing fold in DAGCombiner
handle `uitofp (zext <4 x i32> to <4 x i64>)`, which X86 used to
scalarize. The first commit adds a test for it with the current codegen.
It also lets the generic [su]itofp narrowing fold fire on other vector
extends. LoongArch and X86 both widen narrow vector sources in their own
[su]itofp combines, so the two folds kept undoing each other and
DAGCombiner hung (LoongArch lasx/ir-instruction/uitofp.ll, and X86
select-narrow-int-to-fp.ll with +avx512fp16). I fixed it by making both
targets reject the narrower type in isTypeDesirableForOp(SDNode *, EVT),
the same way SystemZ and AMDGPU already handle it.
[3 lines not shown]
[AArch64][GlobalISel] Add implicit defs for returned phyregs. (#248399)
This fixes a verifier error where physregs for a returned [2 x i64]
argument were not marked as defs on the call, leading them to being
undefined at point of use. As the argument in returned, the register may
be the origin reg used to set up the call, so only physregs need to be
added.
[InstSimplify] Fold vector infinity arms of ninf selects
Reuse m_Inf() for vector constants. When every defined lane of an arm
is an infinity, selecting it yields poison in that lane, so the other
arm is a valid replacement. Keep the select if any lane is finite.
AI assisted.
[Driver][AMDGPU] Search include/hipccl for hipstdpar/rocThrust headers (#246125)
Newer ROCm installs rocThrust under include/hipccl/thrust. Prefer it with --hipstdpar,
falling back to include/thrust.
AI assisted.
Co-authored-by: Yaxun (Sam) Liu <yaxun.liu at amd.com>
DAG: Use poison instead of undef in SimplifyDemandedVectorElts
I left getKnownUndefForVectorBinop since I'm not sure
if it's correct to just replace with poison.
[clangd] Show member names in structured binding inlay hints (#245943)
Show which member each structured binding refers to. For example,
`auto [.name=n: string, age: int] = person;`. The hint is omitted when
the binding has the same name as the member.
The hint is placed before the binding's name, consistent with the
existing
designator hints for aggregate initialization. It is controlled by the
existing `InlayHints.Designators` option.
Fixes clangd/clangd#2727
Assisted-by: Claude Code
Revert #247981 "[RISCV][MC] Diagnose symbol differences in instructions under relaxation" (#248804)
This reverts commit dc963db2bdd1166b5a6fb0fc0d95a6de1a86da4a.
The patch resolves `sym - .` in a PC-relative operand to `sym` by
comparing addresses, so identical lines assemble differently:
```
# llvm-mc -triple=riscv64 -mattr=+relax -filetype=obj a.s
nop
L:
beq a0, a1, X - L
beq a0, a1, X - L # error: unsupported symbol difference in instruction
nop
X:
ret
```
The diagnostic part will reland separately.
[AArch64] Update the Olympus scheduling model as per the SWOG changes (#248907)
The Olympus SWOG
https://docs.nvidia.com/olympus-cpu-core-software-optimization-guide-dp12531-001v0-7.pdf
has been updated for some AArch64 instructions, summarised below. We
update the Olympus scheduling model with updated schedules for the
following instruction groups.
| SWOG group | Old | New |
|---|---|---|
| Reduction (logical) | Lat 6 | Lat 5 |
| Reduction (add, B form) | Lat 11 | Lat 10 |
| Reduction (add, H form) | Lat 9 | Lat 8 |
| Reduction (add, S form) | Lat 8 | Lat 7 |
| Reduction (min/max, B form) | Lat 9 | Lat 8 |
| Reduction (min/max, H form) | Lat 8 | Lat 7 |
| Reduction (min/max, S form) | Lat 6 | Lat 5 |
| Reduction (D form) | Lat 5 (`UADDV` D: n/a, new) | Lat 4 |
| FP reduction (F16) | Lat 8 | Lat 12 |
[4 lines not shown]