26638 Commits

Author SHA1 Message Date
Florian Hahn
c071dba1a3
[LV] update hexagon test to use load results.
The current version of the test doesn't use any of the loads, so they
can be removed together with the mask of the interleave group.

Use some loaded values and store them, to prevent the mask from being
optimized away.
2023-08-22 20:20:58 +01:00
Florian Hahn
34d25924c4
[VPlan] Mark some VPInstruction opcodes as not having side effects.
Mark some VPInstruction opcodes as not having side effects, preparation
for D157037.
2023-08-22 20:05:57 +01:00
Noah Goldstein
39e9862e6b [ValueTracking] Use predicates for incoming phi-edges to deduce non-zero
This is basically a copy and paste of the same logic we do in
`computeKnownBits` but adapts it for just `isKnownNonZero`.

Differential Revision: https://reviews.llvm.org/D157801
2023-08-22 10:59:02 -05:00
Noah Goldstein
99d99eb3b0 [JumpThreading] Regenerate checks for test; NFC
Differential Revision: https://reviews.llvm.org/D157815
2023-08-22 10:59:02 -05:00
Nikita Popov
4a68c27949 [InstCombine] Add tests for nsw propagation in negator (NFC) 2023-08-22 15:17:36 +02:00
Alexey Bataev
b51195dece [SLP]Fix PR63854: Add proper sorting of pointers for masked stores.
If the masked gathers can be reordered, it may produce strided access
pattern and the reordering does not affect common reodering, better to
try to reorder masked gathers for better performance.

Differential Revision: https://reviews.llvm.org/D157009
2023-08-22 06:14:01 -07:00
Alexandros Lamprineas
386aa2ab9d [FuncSpec] Increase the maximum number of times the specializer can run.
* Changes the default value of FuncSpecMaxIters from 1 to 10.
  This allows specialization of recursive functions.
* Adds an option to control the maximum codesize growth per function.
* Measured ~45% performance uplift for SPEC2017:548.exchange2_r on
  AWS Graviton3.

Differential Revision: https://reviews.llvm.org/D145819
2023-08-22 09:36:12 +01:00
Nikita Popov
d82f0b74de [IndVars] Don't assume backedge value is instruction (PR64891)
In degenerate cases, the backedge value can be folded to poison.

Fixes https://github.com/llvm/llvm-project/issues/64891.
2023-08-22 10:33:33 +02:00
Nikita Popov
625113402f [IR] Remove support for and/or constant expressions
As part of https://discourse.llvm.org/t/rfc-remove-most-constant-expressions/63179,
this removes support for and and or constant expressions. Places
creating such expressions have been migrated in advance, so this
is mostly API removal and test updates.

Differential Revision: https://reviews.llvm.org/D155924
2023-08-22 09:29:54 +02:00
Nikita Popov
1c6e6432ca [SCEVExpander] Fix incorrect reuse of more poisonous instructions (PR63763)
SCEVExpander tries to reuse existing instruction with the same
SCEV expression. However, doing this replacement blindly is not
safe, because the instruction might be more poisonous.

What we were already doing is to drop poison-generating flags on
the reused instruction. But this is not the only way that more
poison can be introduced. The poison-generating flag might not
be directly on the reused instruction, or the poison contribution
might come from something like 0 * %var, which folds to 0 but can
still introduce poison.

This patch fixes the issue in a principled way, by determining which
values can contribute poison to the SCEV expression, and then
checking whether any additional values can contribute poison to the
instruction being reused. Poison-generating flags are dropped if
doing that enables reuse.

This is a pretty big hammer and does cause some regressions in
tests, but less than I would have expected. I wasn't able to come
up with a less intrusive fix that still satisfies the correctness
requirements.

Fixes https://github.com/llvm/llvm-project/issues/63763.
Fixes https://github.com/llvm/llvm-project/issues/63926.
Fixes https://github.com/llvm/llvm-project/issues/64333.
Fixes https://github.com/llvm/llvm-project/issues/63727.

Differential Revision: https://reviews.llvm.org/D158181
2023-08-22 09:27:07 +02:00
Kolya Panchenko
acbe886880 [LV] Vectorization remark for outerloop
Reviewed By: fhahn, ABataev

Differential Revision: https://reviews.llvm.org/D150696
2023-08-21 13:05:06 -04:00
Harvin Iriawan
db158c7c83 [AArch64] Update generic sched model to A510
Refresh of the generic scheduling model to use A510 instead of A55.
  Main benefits are to the little core, and introducing SVE scheduling information.
  Changes tested on various OoO cores, no performance degradation is seen.

  Differential Revision: https://reviews.llvm.org/D156799
2023-08-21 12:25:15 +01:00
Nikita Popov
69bd66b3ce [Tests] Remove some and/or constant expressions in tests (NFC)
In preparation for their removal in D158081.
2023-08-21 12:05:32 +02:00
Maksim Kita
341443d731 [InstCombine] Fold (-a >> b) and/or/xor (~a >> b) into (-a and/or/xor ~a) >> b
Fold (-a >> b) and/or/xor (~a >> b) into (-a and/or/xor ~a) >> b.
Depends on D157289.

Differential Revision: https://reviews.llvm.org/D157290
2023-08-21 12:49:20 +03:00
Maksim Kita
f5130a578e [InstCombine] Fold (-a >> b) and/or/xor (~a >> b) into (-a and/or/xor ~a) >> b tests
Precommit tests for D157290.

Differential Revision: https://reviews.llvm.org/D157289
2023-08-21 12:49:20 +03:00
Carlos Alberto Enciso
bf69217bae [instcombine] Sunk instructions with invalid source location.
When the 'int Four = Two;' is sunk into the 'case 0:' block,
the debug value for 'Three' is set incorrectly to 'poison'.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D158171
2023-08-21 06:24:21 +01:00
Johannes Doerfert
9c08e76f3e [Attributor] Introduce AAIndirectCallInfo
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.

This effectively "fixes" #60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.

Fixes: https://github.com/llvm/llvm-project/issues/60327
2023-08-18 16:44:05 -07:00
Alexey Bataev
9a207578ac [TTI]Add InsertSubvector pattern in improveShuffleKindFromMask().
It improves shuffle instructions estimation and improves vectorization
outcome.

Differential Revision: https://reviews.llvm.org/D157425
2023-08-18 13:47:01 -07:00
Anna Thomas
23f08af2be [Inline] Avoid incompatible return attributes on deoptimize
When updating the return type of deoptimize call during inline, we need
to drop incompatible return attributes.  This bug was exposed once we
relaxed the contraint of adding the attributes through D156844. With
that change deoptimize (are not willreturn) will start having return
attributes added to it.

Fixes https://github.com/llvm/llvm-project/issues/64804.

Differential Revision: https://reviews.llvm.org/D158286
2023-08-18 12:55:51 -04:00
Florian Hahn
686aef8401
[LV] Remove compares and branches on undef from a few tests. 2023-08-18 16:28:42 +01:00
Aleksandr Popov
1b87882228 [LoopPredication] Rework assumes of widened conditions
Currently after widening br(WC && (c1 && c2)) we insert assume of
(c1 && c2) which is joined to WC by And operation.
But we are going to support more flexible form of widenable branches
where WC could be placed arbitrary in the expression tree, e.g:
br(c1 && (c2 && WC)).
In that case we won't have (c1 && c2) in the IR. So we need to add
explicit (c1 && c2) and then create an assumption of it.

Reviewed By: anna

Differential Revision: https://reviews.llvm.org/D157502
2023-08-18 14:35:46 +02:00
Pravin Jagtap
5f8fd68672 [AMDGPU] Pre-commit test for D157495
Reviewed By: yassingh

Differential Revision: https://reviews.llvm.org/D158243
2023-08-18 06:52:32 -04:00
Johannes Doerfert
5eb7a427b0 [Attributor][NFC] Precommit tests 2023-08-17 22:42:38 -07:00
Johannes Doerfert
361b536bbc [Attributor] Simplify switches with more than one potential condition
Before, we allowed the condition to be simplified to a simple constant
only, otherwise we assumed all successors are live. Now we allow
multiple constants, and mark the default successor as dead accordingly.
2023-08-17 22:42:38 -07:00
Johannes Doerfert
fb0e49f230 [OpenMP] Add noalias to runtime allocator functions 2023-08-17 19:25:32 -07:00
Johannes Doerfert
bfa1afb81c [OpenMPOpt] Improve __kmpc_alloc_shared handling
We know that __kmpc_alloc_shared is by construction matched with a
unique __kmpc_free_shared. Making the compiler aware of these facts
helps to avoid mallocs/allocas.

Fixes: https://github.com/llvm/llvm-project/issues/64551
2023-08-17 19:25:32 -07:00
Johannes Doerfert
4fcd5f93d6 [OpenMPOpt] Mark more runtime functions as SPMD compatible
Fixes: https://github.com/llvm/llvm-project/issues/64421
2023-08-17 18:33:24 -07:00
Johannes Doerfert
2ece6d939b [OpenMPOpt] SPMD-amenable implies no unknown parallel regions 2023-08-17 18:33:23 -07:00
DianQK
3aed00239c
[Coroutine][DebugInfo] Reduced test case for coro-async-declaration.ll. (NFC)
Based on the description at https://reviews.llvm.org/D157177#inline-1529005, I try to improve the test case.

Reviewed By: fdeazeve

Differential Revision: https://reviews.llvm.org/D158178
2023-08-17 22:24:38 +08:00
Felipe de Azevedo Piovezan
8aa038ab17 [CoroSplit][DebugInfo] Don't use entry_value in coroutine entry point
The entry point function is called as a regular function. Among other things, it
can be inlined, which would violate the semantics of entry_value in the IR.

Differential Revision: https://reviews.llvm.org/D158108
2023-08-17 09:15:17 -04:00
David Spickett
2121e35ac2 Revert "[InstCombine] Expand foldSelectICmpAndOr -> foldSelectICmpAndBinOp to work for more binops"
This reverts commit d3402bc4460acefbc3d5278743601fa090784614.

This has caused a second stage build failure on one of our Armv7 32 bit builders:
https://lab.llvm.org/buildbot/#/builders/182/builds/7193
2023-08-17 10:13:47 +00:00
Florian Hahn
9851edfc6c
[ConstraintElim] Add ptr phi tests without inbounds.
Extra test coverage for D152730.
2023-08-17 11:09:56 +01:00
Florian Hahn
ca0d3c99e1
[ConstraintElim] Add bottom tested loops with EQ predicates.
Extra test coverage for D152730.
2023-08-17 11:09:19 +01:00
Florian Hahn
b7a95ad467
[SimplifyCFG] Don't sink loads/stores with swifterror pointers.
swifterror pointers can only be used as pointer operands of load & store
instructions (and as swifterror argument of a call). Sinking loads or
stores with swifterror pointer operands would require introducing a
select of of the pointer operands, which isn't allowed.

Check for this condition in canSinkInstructions.

Reviewed By: aschwaighofer

Differential Revision: https://reviews.llvm.org/D158083
2023-08-17 09:59:07 +01:00
Sameer Sahasrabuddhe
8dce4c56dd [Inliner] Handle convergence control when inlining a call
When a convergencectrl token is passed to a convergent call, and the called
function in turn calls the entry intrinsic, the intrinsic is now now replaced
with the convergencectrl token.

The spec requires the following check:
  A call from function F to function G can be inlined only if:
  - at least one of F or G does not make any convergent calls, or,
  - both F and G make the same kind of convergent calls: controlled or
    uncontrolled.

But this change does not implement this complete check. A proper implemenation
require a whole new analysis that identifies convergence in every function. For
now, we skip that and just do a cursory check for the entry intrinsic. The
underlying assumption is that in a compiler flow that fully implements
convergence control tokens, there is no mixing of controlled and uncontrolled
convergent operations in the whole program.

This is a reboot of the original change D85606 by
Nicolai Haehnle <nicolai.haehnle@amd.com>.

Reviewed By: arsenm, nhaehnle

Differential Revision: https://reviews.llvm.org/D152431
2023-08-17 09:56:25 +05:30
Noah Goldstein
d3402bc446 [InstCombine] Expand foldSelectICmpAndOr -> foldSelectICmpAndBinOp to work for more binops
This just expands on the existing logic that worked for `Or` and
applies it to any binop where `0` is the identity value on the RHS
i.e: `add`, `or`, `xor`, `shl`, etc...

Proofs For Some: https://alive2.llvm.org/ce/z/XZo6JD

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D148414
2023-08-16 22:43:05 -05:00
Noah Goldstein
82292d1ae5 [InstCombine] Remove requirement on trunc in slt/sgt case in foldSelectICmpAndOr
AFAICT, the trunc is not needed for correctness/performance and just
blocks what should be handlable cases.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D148413
2023-08-16 22:43:05 -05:00
Noah Goldstein
4bfd763376 [InstCombine] Add tests for (select (icmp x, Cp2_0), (binop y, Cp2_1), y); NFC
Differential Revision: https://reviews.llvm.org/D148411
2023-08-16 22:43:05 -05:00
Noah Goldstein
4d51c6258e [Inliner] Add return attributes to callsites not marked willreturn/nounwind
The actual callsite we are adding to doesn't need to be
`willreturn`/`nounwind`, only ever instructions between the callsite
and the return.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D156844
2023-08-16 22:43:04 -05:00
Noah Goldstein
612a7f0b15 [Inliner] Add the callsites called function return attributes to set addable attributes
We can do this by just querying attribute in the callsite itself. This
is both cleaner code and produces bette results.

Differential Revision: https://reviews.llvm.org/D156843
2023-08-16 22:43:04 -05:00
Noah Goldstein
74c4d1e422 [Inliner] Add more tests for deducing return attributes of callsites when inlining; NFC
Differential Revision: https://reviews.llvm.org/D156842
2023-08-16 22:43:04 -05:00
Noah Goldstein
9c375a457e [InstCombine] Transform (add (shl (neg X), Cnt)) -> (sub (shl X, Cnt))
Just a simple instruction save.

Proof: https://alive2.llvm.org/ce/z/Vb484j

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D154807
2023-08-16 22:43:04 -05:00
Noah Goldstein
a6c022818d [InstCombine] Add tests for transforming (add (shl (neg X), Cnt)); NFC
Differential Revision: https://reviews.llvm.org/D154806
2023-08-16 22:43:04 -05:00
Dhruv Chawla
d53b3df570
[InstCombine] Remove unneeded isa<PHINode> check in foldOpIntoPhi
This check is redundant as it is covered by the call to
isPotentiallyReachable.

Depends on D155726.

Differential Revision: https://reviews.llvm.org/D155718
2023-08-16 21:09:08 +05:30
Dhruv Chawla
e549d578cc
[InstCombine] Test cases for D155718
Differential Revision: https://reviews.llvm.org/D155726
2023-08-16 21:09:04 +05:30
Matt Arsenault
7c4aa3b37e AMDGPU: InstCombine amdgcn.rcp(amdgcn.sqrt) -> amdgcn.rsq
We currently have some wrong combines in the backend that
approximately do this.

https://reviews.llvm.org/D158002
2023-08-16 10:04:13 -04:00
Matt Arsenault
f19ee76f35 AMDGPU: Add baseline tests for rcp to rsq fold 2023-08-16 10:03:49 -04:00
Florian Hahn
5816d2ab28
[SimplifyCFG] Add tests for sinking load/store with swifterror operand.
Add test coverage for sinking/hoisting loads/stores with swifterror
pointers. Currently this isn't handled correctly by SimplifyCFG and
causes a verifier error.
2023-08-16 14:51:29 +01:00
Nikita Popov
7e2f1ae7e0 Reapply [CHR] Fix up phi nodes with unreachable predecessors (PR64594)
Relative to the previous attempt, this also adjusts RegionInfo
verification to allow unreachable predecessors.

-----

If a block in the CHR region has an unreachable predecessor, then
there will be no edge from that predecessor to the newly cloned
block. However, a phi node entry for it will be left behind. Make
sure that these incoming blocks get dropped as well.

Fixes https://github.com/llvm/llvm-project/issues/64594.

Differential Revision: https://reviews.llvm.org/D157621
2023-08-16 10:07:32 +02:00
Nikita Popov
6f3f600b2a [Inline] Add test for simplification in loop (NFC)
This would have been miscompiled by D157816.
2023-08-16 09:27:01 +02:00