[GlobalISel][Docs] Fix known-bits example and code snippet in KnownBits.rst (#213090)
- The simplified example annotates `%5 = G_CONSTANT i32 0x0F0` with the
value `0x00000FF0` (from %1 line); correct value is `0x000000F0`.
- `GISelValueTrackingAnalysisLegacy::get(MF)` returns a reference, so
call should be `VT.getKnownBits(...)` not `VT->getKnownBits(...)`.
- `KnownBits` members are `Zero` and `One`, not `Zeros`; use
`Known.Zero[0]` to test bit 0.
[Polly] Narrow IV to lower type when possible (#212708)
This patch tries to lower the LLVM-IR type of IVs which are set to i64
by default during polly codegen. This is specially beneficial for
Hexagon as it uses Hardware Loops which requires 32 bit wide IVs.
---------
Co-authored-by: Anilava Kundu <anilkund at hu-anilkund-blr.qualcomm.com>
Co-authored-by: Santanu Das <santdas at qti.qualcomm.com>
[LoongArch] Fold shifted vector extract comparisons
Fold comparisons of the form:
(shl (extract_vector_elt X, I), GRLen - EleBits) ==/!= 0
into:
(extract_vector_elt X, I) ==/!= 0
When the shift amount equals `GRLen - EleBits`, the left shift only moves
the extracted element into the most significant bits without affecting
whether the value is zero. This canonicalization exposes
EXTRACT_VECTOR_ELT to later combines and enables selecting
VPICKVE2GR_* instructions directly.
[SCEV][SCEVExpander] Avoid querying SCEV for non-SCEVable instructions (#214902)
`getStrengthenedNoWrapFlagsFromBinOp()` expects instructions with
SCEVable operands.
For non-SCEVable vector-typed operands, this triggers the assertion in
`getSCEV()`.
This PR guards the caller in
`dropPoisonGeneratingAnnotationsAndReinfer()` so that
nowrap flags are only re-inferred for SCEVable instructions.
The added test is a crash regression test.
Fixes #214782
Fixes #215251
Fixes #114029
[Lanai] Default to NewPM
Lanai should be fully functional with the NewPM, so try defaulting to
it. Also remove the now duplicate test coverage.
Setting this flag makes both clang and llc default to the NewPM.
Reviewers: jpienaar
Pull Request: https://github.com/llvm/llvm-project/pull/214574
[MSP430] Default to NewPM
MSP430 should be fully complete with the NewPM, so default to it.
This flag makes both clang and llc default to using the NewPM for
CodeGen.
Reviewers: asl
Pull Request: https://github.com/llvm/llvm-project/pull/214573
[CodeGen] Avoid querying allocation order for every CSR alias (#215752)
Profiling tramp3d-v4 on aarch64-O0-g shows ~0.30% of compile-time is
spent in RegisterClassInfo::runOnMachineFunction.
It currently walks every alias of every callee-saved register for every
MachineFunction, doing a virtual call to ignoreCSRForAllocationOrder for
each alias. ARM is the only target that overrides this hook; all other
targets construct a full-sized BitVector and perform the alias traversal
only to fill it with zeroes.
Replace the per-register hook with a target-populated mask. Most targets
leave the mask empty, avoiding the allocation and alias traversal. The
mask is also only consulted after getLastCalleeSavedAlias confirms the
physical register aliases a CSR, so ARM can populate all GPR bits
directly without rediscovering the CSR aliases.
Improves CTMark geomean by -0.10%, with tramp3d-v4 -0.34%.
[2 lines not shown]
[SandboxVectorizer] Dispatch LoadStoreVec::runOnRegion on seed kind
runOnRegion() previously assumed its seed slice was always a store chain,
unconditionally casting Bndl[0] to StoreInst. This crashed (assertion in
areConsecutive<StoreInst>) whenever -sbvec-collect-seeds included "loads",
since a load-seeded region's Aux holds LoadInsts.
Add a symmetric top-level path for load-kind seed slices: createVectorLoad()
builds the vector load, and vectorizeLoads() -- unlike a load that merely
feeds a store -- has to handle arbitrary uses, so it replaces each original
load with an extract from the vector load (VecUtils::unpack()) rather than
just discarding it. runOnRegion() determines the seed kind from Bndl[0]
(asserting the slice is homogeneous, which SeedCollection guarantees) and
dispatches to vectorizeStores()/vectorizeLoads() accordingly.
No sub-run search yet: vectorizeStores()/vectorizeLoads() are each still
tried once over the whole seed slice, same as before this commit for
stores. Sub-bundle partitioning for both kinds is a separate follow-up.
[13 lines not shown]
[llc] Respect shouldDefaultToNewPM
This makes llc respect the new TM flag that allows targets to opt in to
defaulting to the NewPM.
Reviewers: vikramRH, aengelke, arsenm
Pull Request: https://github.com/llvm/llvm-project/pull/214572
[Clang] Make NewPM switch respect shouldDefaultToNewPM
shouldDefaultToNewPM is a new target flag that allows targets to specify
that the NewPM should be used by default for compilation. Wire it up
into clang.
Reviewers: arsenm, efriedma-quic, jansvoboda11
Pull Request: https://github.com/llvm/llvm-project/pull/214571
[RISCV][P-ext] Select scalar mulhr/mulhru/mulhrsu for RV32 v2i32 (#215938)
The `combinePExtTruncate` DAGCombine bailed out on RV32 for both
`v4i16` and `v2i32` 64-bit packed types. The `v4i16` case is correct
(no paired rounding multiply-high for 16-bit lanes), but `v2i32` was
incorrectly excluded.
RV32 provides scalar `mulhr`/`mulhru`/`mulhrsu` instructions. Since
`v2i32` on RV32 is a GPRPair, splitting into two scalar operations in
the combine — while the widening multiply shape is still visible —
reuses those instructions directly.
The non-rounding forms (`mulh`/`mulhu`/`mulhsu`) already scalarize
correctly through the generic legalizer, so only the rounding case
needs explicit handling here.
[SandboxVectorizer] Vectorize partial store sub-bundles in LoadStoreVec
runOnRegion() previously required an entire store seed chain to vectorize
as one unit. A seed slice can legitimately fail that as a whole while a
sub-run within it is still fine, e.g. because it spans an address gap
(SeedBundle::getSlice sorts by address but doesn't guarantee contiguity)
or a sub-range fails to schedule. Add findLegalStoreRun()/isLegalStoreRun()
to search for the longest vectorizable run starting at a given position,
and have runOnRegion() call vectorizeStores() once per such run instead of
once for the whole chain. isLegalStoreRun() is purely an address/scheduling
check now -- no operand-eligibility check is needed since packOperands()
accepts any operand kind.
The search only ever shrinks a candidate length, never grows one:
Scheduler::trySchedule() permanently commits a successful multi-instruction
bundle (a later request that overlaps it and is not an exact match returns
AlreadyScheduled and fails), so starting from the longest candidate and
shrinking on failure is the only search order compatible with the
scheduler's contract.
[18 lines not shown]
[SandboxVectorizer] Make LoadStoreVec::vectorizeStores direction-agnostic
Remove the AllLoads/AllConstants operand-kind gate: vectorizeStores() no
longer requires a store chain's value operands to be all loads, all
constants, or neither. Instead it always builds the vector value via
packOperands(), which packs any mix of loads, constants, or arbitrary SSA
values via extractelement/insertelement -- direction-agnostic in the sense
that it doesn't care what kind of operand it's given, unlike the
load-specific and constant-specific paths it replaces.
vectorizeLoads()/createVectorLoad(), added by the previous commit for
load-kind seed slices, are unaffected: packOperands() only replaces
vectorizeStores()'s old all-loads fast path, which duplicated the same
vector-load construction createVectorLoad() already does.
Update load_store_vec.ll, load_store_vec_mixed_types.ll, and
AMDGPU/basic.ll for the new pack-based codegen.
check-llvm Transforms/SandboxVectorizer passes (31/31).