[LV] Expand IR AddRecs from VPSCEVExpander in SafeUDivMode. (#240209)
VPSCEVExpander leaves some expressions for expansion in IR. Those may
get hoisted and executed before other runtime checks (like SCEV
predicate checks).
The expressions may only be valid if the SCEV predicates hold. For
example, a runtime check bound with an outer loop AddRec with step
%m /u (%stride + %y) becomes %m /u (%y + 1) after applying
%stride == 1, which divides by zero for %y == -1 and %stride != 1,
while the original loop is well defined.
Expand SCEVs via IR expander in SafeUDivMode, exposed via a
new constructor parameter, so they cannot cause UB.
[GVNHoist] Propogate getClobberingMemoryAccess after moveToPlace
getDefiningAccess in sfaeToHoistLdSt returns the nearest stores
if we don't query AA result by using getClobberingMemoryAccess. This
reduce the opportunity for optimization in sfaeToHoistLdSt as
isLiveOnEntryDef returns false without updating.
In the example (See Closes item): after hosting left.a and left.b,
getDefiningAccess returns `store q` before.
As a result, we call getClobberingMemoryAccess after relink the
hoisted expression.
Assisted-by: Claude # Test
Closes: #221578
[VPlan] Hoist sums of invariant operands of adds in runtime checks. (#240190)
When expanding a variant integer add for the runtime checks of an inner
loop in a loop nest, operands invariant in the outer loop were hoisted
individually during IR SCEV expansion.
Update VPlan-based SCEV epander to expand the sum of the invariant
operands plus the sum of the others, so the invariant sum is expanded in
IR and hoisted out of the outer loop.
[SLP]Do not form scalar reduction roots with external lane uses
Narrowed reductions keep chains with extra uses alive, so their leaves
need extracts from the root vector, which bitcast and bit pack roots
do not produce.
Fixes #240152
Assisted-by: Cursor
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/240216
[ELF] Symbol::resolve: Remove dead discardedSecIdx condition. NFC (#240213)
initializeSymbols used to call `resolve` with such an Undefined for a
global symbol defined in a discarded COMDAT member. Since D120626 all
callers pass discardedSecIdx=0 (except combineVersionedSymbol where
`this` is a Defined).
[SLP]Fix signedness of the last narrow part in split reductions
If the other parts are reduced in tree, the remaining narrow vector part
was extended to the reduction type with zext, ignoring its signedness.
Fixes #240151
Assisted-by: Cursor
Reviewers:
Pull Request: https://github.com/llvm/llvm-project/pull/240211
[GVNHoist] Make nested GEPs check corresponding Instructions
A nested GEP of a load/store was originally check the direct parent of
the load store. This makes us unable to correctly relax the flags for
the innermost GEP.
The simple example is in here:
```
b = gep a
c = gep b
d = load c
```
In the orignal implementation, the merging always uses gep b, this
causes gep a are unable to detect.
Assisted-by: Cluade # Test
Closes: #237085
[ADT] Add LLVM_ATTRIBUTE_WARN_UNUSED to SmallString (#240180)
This patch adds LLVM_ATTRIBUTE_WARN_UNUSED to SmallString so that
compilers can diagnose unused SmallString variables even though
SmallString has a non-trivial constructor and destructor.
This patch also removes an unused local variable Path in
VirtualOutputBackendsTest.cpp uncovered by the attribute.
Assisted-by: Antigravity
[NFC][SPIRV] Clean up the Global Registry when removing an instruction (#239297)
This fixes a relatively quaint bug, that only seems to trigger with .bc
inputs. Here's what I believe is happening:
- during intrinsic emission we might have to update assign pointer type
instructions, as a consequence of mutating an instruction;
- the old / non mutated instruction is erased, as is the old type
assignment, but its entry in the map from instruction to assigned type
maintained by the Global Registry is not erased;
- during subsequent processing, as a consequence of new instructions
getting created, the address of the old, now erased instruction, appears
to be re-used;
- due to the re-use, we can end up in a circumstance wherein we index
into the assigned type map via the re-used address and retrieve the now
invalid / dead `assign.type` instruction.
The fix is to a just add an interface that allows the simple removal /
erasure of an entry from the map (we already have `add` and `update`),
[7 lines not shown]
[LV] Treat all blocks as predicated for early exits with side effects. (#232408)
For uncountable exits with side effects, all memory accesses except the
uncountable exit condition load are masked on the VPlan-level. Legal
already marks them as requiring a mask.
Also return true from blockNeedsPredicationForAnyReasonif the loop has
an uncountable exit with side effects.
PR: https://github.com/llvm/llvm-project/pull/232408
[M68k] Declare command line options in TableGen (#240195)
Move -m68k-use-base-pointer into M68kOptions.td and
-m68k-register-prefix-optional into MCTargetDesc/M68kMCOptions.td.
M68kTargetMachine holds `const M68kOptions &CLOpts`, and M68kSubtarget
copies it; M68kAsmParser holds `const M68kMCOptions &CLOpts`.
Delete the unused -m68k-ssection-threshold.