25953 Commits

Author SHA1 Message Date
Florian Hahn
06dab8f743
[ConstraintElim] Extend monotonic phi test coverage.
Add additional tests which exposed some crashes in upcoming patches and
test for and-implied-by-operands handling.
2023-06-12 17:07:36 +01:00
Nikita Popov
2b7c347c7f [LoopVectorize] Convert test to opaque pointers (NFC)
I'm keeping the bitcast in the input here, because without it
we end up introducing a stride 1 assumption and end up testing
a different case.
2023-06-12 14:49:45 +02:00
Nikita Popov
9929f9533d [LoopVectorize] Convert test to opaque pointers (NFC) 2023-06-12 14:31:54 +02:00
Nikita Popov
aa92ae5924 [LoopVectorize] Regenerate test checks (NFC) 2023-06-12 14:31:54 +02:00
Nikita Popov
9cf67f6ea0 [LoopVectorize] Convert most tests to opaque pointers (NFC)
The unsized-pointee-crash.ll and zero-sized-pointee-crash.ll tests
have been removed, because these issues are not relevant for opaque
pointers.
2023-06-12 13:10:22 +02:00
luxufan
cf79773a90 [SCCP] Replace new value's value state with removed value's
In replaceSignedInst, if a signed instruction can be repalced with
unsigned instruction, we created a new instruction and removed the old
instruction's value state. If the following instructions has this new
instruction as a use operand, transformations like replaceSignedInst and
refineInstruction would be blocked. The reason is there is no value
state for the new instrution.

This patch set the new instruction's value state with the removed
instruction's value state. I believe it is correct bacause when we
repalce a signed instruction with unsigned instruction, the value state
is not changed.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D152337
2023-06-12 11:40:47 +08:00
Antonio Frighetto
1774c14816 [ConstraintElimination] Handle ICMP_EQ predicates
Simplification of equality predicates is now supported by
transferring equalities into inequalities. This is achieved
by separately checking that both `isConditionImplied(A >= B)`
and `isConditionImplied(A <= B)` hold.

Differential Revision: https://reviews.llvm.org/D152067
2023-06-11 15:22:31 +02:00
Florian Hahn
6162f6e9ff
[ConstraintElim] Add additional monotonic phi tests.
Add extra test coverage with cases that showed mis-compiles in earlier
versions of an upcoming patch. Also add tests for integer phis
2023-06-10 21:43:06 +01:00
Noah Goldstein
5189eff345 [InstCombine] Canonicalize (icmp eq/ne X, rotate(X)) to always use rotate-left
We canonicalize rotate-right -> rotate-left in other places. Makes
sense to do so here as well.
Proof: https://alive2.llvm.org/ce/z/HL3TpK

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D152349
2023-06-10 14:38:46 -05:00
Noah Goldstein
2df6309555 [InstCombine] Transform (icmp eq/ne rotate(X,AX),rotate(Y,AY)) -> (icmp eq/ne rotate(Y,AX-AY))
Only do so if we don't create more instructions, so either both
rotates have one use or one of the rotates has one use and both `AX`
and `AY` are constant.
Proof: https://alive2.llvm.org/ce/z/rVmJgz

Differential Revision: https://reviews.llvm.org/D152348
2023-06-10 14:38:46 -05:00
Noah Goldstein
1ce0265230 [InstCombine] Add tests for equality icmp with rotates; NFC
Differential Revision: https://reviews.llvm.org/D152347
2023-06-10 14:38:45 -05:00
Matt Arsenault
5b657f50b8 AMDGPU: Move LICM after AMDGPUCodeGenPrepare
The commit that added the run says it's to hoist uniform parts of
integer division expansion. That expansion is performed later, so this
didn't do anything in that case. Move this later so the original test
shows the improvement.

This also saves a run of "Canonicalize natural loops". Not sure why
this appears to be still getting a separate loop PM run. Also feels a
bit heavy to run this just for divide. Is there a way to specifically
hoist the divide sequence when it expands?
2023-06-10 07:37:32 -04:00
Nuno Lopes
7ffeb8efe8 PromoteMem2Reg: use poison instead of undef as placeholder in phi entries from unreachable predecessors [NFC] 2023-06-10 11:19:03 +01:00
luxufan
25d9fde22e [SCCP] Skip computing intrinsics if one of its args is unknownOrUndef
For constant range supported intrinsics, we got consantrange from args
no matter if they are unknown or undef. And the constant range computed
from unknown or undef value state is full range.

I think compute with full constant range is harmful since although we
can do mergeIn after these args value state are changed, the merge
operation of two constant ranges is union.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D152499
2023-06-10 15:48:46 +08:00
luxufan
3abdd40129 [SCCP][NFC] Precommit test 2023-06-10 15:37:09 +08:00
khei4
361464c027 [MemCpyOpt] Use memcpy source directly if dest is known to be immutable from attributes
Differential Revision: https://reviews.llvm.org/D150970
2023-06-10 15:46:32 +09:00
khei4
f0d97c30e9 [MemCpyOpt] precommit test for memcpy removal for immutable arguments from attributes (NFC)
Differential Revision: https://reviews.llvm.org/D150967
2023-06-10 15:46:32 +09:00
Matt Arsenault
a393870085 AMDGPU: Extract test out of old patch
Don't think the patch is still useful but I don't see equivalent tests
for decreased alloca alignment.

https://reviews.llvm.org/D23908
2023-06-09 21:53:33 -04:00
Matt Arsenault
19293b82c1 Inline: Fix case of not inlining with denormal-fp-math-f32
This was failing to inline the opencl libraries with daz enabled. As a
modifier to the base mode, denormal-fp-mode-f32 is weird and has no
meaning if it's missing.
2023-06-09 19:09:48 -04:00
Matt Arsenault
d0b9cb1f65 AMDGPU: Add inlining testcases for denormal-fp-math
Somehow missed this one and it's not working correctly
2023-06-09 19:09:48 -04:00
John McIver
1001f9031f [InstCombine] Optimize and of icmps with power-of-2 and contiguous masks
Add an instance combine optimization for expressions of the form:

(%arg u< C1) & ((%arg & C2) != C2) -> %arg u< C2

Where C1 is a power-of-2 and C2 is a contiguous mask starting 1 bit below
C1. This commit resolves GitHub missed-optimization issue #54856.

Validation of scalar tests:
  - https://alive2.llvm.org/ce/z/JfKjiU
  - https://alive2.llvm.org/ce/z/AruHY_
  - https://alive2.llvm.org/ce/z/JAiR6t
  - https://alive2.llvm.org/ce/z/S2X2e5
  - https://alive2.llvm.org/ce/z/4cycdE
  - https://alive2.llvm.org/ce/z/NcDiLP

Validation of vector tests:
  - https://alive2.llvm.org/ce/z/ABY6tE
  - https://alive2.llvm.org/ce/z/BTJi3s
  - https://alive2.llvm.org/ce/z/3BKWpu
  - https://alive2.llvm.org/ce/z/RrAbkj
  - https://alive2.llvm.org/ce/z/nM6fsN

Reviewed By: goldstein.w.n

Differential Revision: https://reviews.llvm.org/D125717
2023-06-09 16:07:01 -06:00
John McIver
ea868d5748 [InstCombine][NFC] Add tests pre-implementation of issue #54856
Provide both positive and negative testing using scalar and vector values for
issue #54856.

Reviewed By: goldstein.w.n

Differential Revision: https://reviews.llvm.org/D143044
2023-06-09 16:07:01 -06:00
Jay Foad
c0ad1b4597 [NewGVN] Fold equivalent freeze instructions
Differential Revision: https://reviews.llvm.org/D152529
2023-06-09 20:57:36 +01:00
Jay Foad
b27b5dcc00 [NewGVN] Precommit test for folding freeze
Differential Revision: https://reviews.llvm.org/D152528
2023-06-09 20:57:36 +01:00
Jay Foad
18f5446a45 [GVN] Fix typo in freeze test case
Differential Revision: https://reviews.llvm.org/D152539
2023-06-09 15:41:32 +01:00
Bjorn Pettersson
8813c1087e [SLP] Update X86/schedule_budget.ll test case to show budget impact
The comments and the checks in
  test/Transforms/SLPVectorizer/X86/schedule_budget.ll
did not match. After commit 352c46e70716061e99 the vectorization
has happened also with the reduced budget.

This patch is supposed to restore the original intention with the
test case (the one described in the comments). We want to see
that a restricted budget may reduce the amount of vectorization (i.e.
verifying that the -slp-schedule-budget option makes a difference),
while a higher budget still result in vectorization.

Differential Revision: https://reviews.llvm.org/D152530
2023-06-09 15:33:35 +02:00
Bjorn Pettersson
263bc7f905 [LoadStoreVectorizer] Only upgrade align for alloca
In commit 2be0abb7fe72ed453 (D149893) the load store vectorized was
reimplemented. One thing that can happen with the new LSV is that
it can increase the align of alloca and global objects. However,
the code comments indicate that the intention only was to increase
alignment of alloca.
Now we will use stripPointerCasts to analyse if the load/store really
is accessing an alloca (same as getOrEnforceKnownAlignment is using).
And then we only try to change the align if we find an alloca
instruction. This way the code will match better with code comments,
and we won't change alignment of non-stack variables to use the
"StackAdjustedAlignment".

Differential Revision: https://reviews.llvm.org/D152386
2023-06-09 15:33:35 +02:00
Jay Foad
63901cb082 [Scalarizer] Scalarize freeze instruction
Differential Revision: https://reviews.llvm.org/D152518
2023-06-09 13:54:24 +01:00
Jay Foad
f5b22f50b8 [Scalarizer] Precommit tests for freeze instruction
Differential Revision: https://reviews.llvm.org/D152517
2023-06-09 13:54:24 +01:00
Graham Hunter
95bfb1902d [LV][AArch64] Allow (limited) interleaving for scalable vectors
This patch uses the (de)interleaving intrinsics introduced in
D141924 to handle vectorization of interleaving groups with a
factor of 2 for scalable vectors.

Reviewed By: fhahn, reames

Differential Revision: https://reviews.llvm.org/D145163
2023-06-09 11:42:10 +01:00
Nikita Popov
cde681c865 [InstCombine] Replace phi operands in successors of unreachable block
Set these operands to poison, which might allow folding the phi node,
or reduce the use count of an instruction.
2023-06-09 12:31:07 +02:00
Nikita Popov
185f2aefea [InstCombine] Add tests for phi nodes with dead edges (NFC) 2023-06-09 11:34:50 +02:00
David Green
a5fc9893ac [TypePromotion] Don't treat bitcast as a Source
This removes BitCasts from isSource in Type Promotion, as I don't believe they
need to be treated as Sources. They will usually be from floats or hoisted
constants, where constants will be handled already.

This fixes #62513, but didn't otherwise cause any differences in the tests I
ran.

Differential Revision: https://reviews.llvm.org/D152112
2023-06-09 08:32:26 +01:00
Dmitry Makogon
995a26d2c7 [SimpleLoopUnswitch] Verify LoopInfo in turnGuardIntoBranch under a flag
A follow-up for 64397d8. Only do verification if VerifyLoopInfo is
set.
2023-06-09 13:44:55 +07:00
Florian Hahn
c317a88767
[LV] Add tests for reasoning about SCEV predicates.
Add extra tests with cases where SCEV predicates can be proven to always
be false. The test in pointer-induction.ll has been adjusted to avoid
the induction always to wrap.
2023-06-08 21:13:06 +01:00
Alexandros Lamprineas
475ddca56e Reland "[FuncSpec] Replace LoopInfo with BlockFrequencyInfo"
Using AvgLoopIters on any loop is too imprecise making the cost model
favor users inside loop nests regardless of the actual tripcount.

Differential Revision: https://reviews.llvm.org/D150375
2023-06-08 17:44:47 +01:00
Teresa Johnson
4638eb2660 [ThinLTO] Ignore callee edge to global variable
Since the symbols in the ThinLTO summary are indexed by GUID we can end
up in corner cases where a callee edge in the combined index goes to a
summary for a global variable. This could happen in the case of hash
collisions, and in the case of SamplePGO profiles could potentially happen
due to code changes (since we synthesize call edges to GUIDs that were
inlined callees in the profiled code).

Handle this by simply ignoring any non-FunctionSummary callees.

Differential Revision: https://reviews.llvm.org/D152406
2023-06-08 06:44:06 -07:00
Dmitry Makogon
64397d8f25 [SimpleLoopUnswitch] Verify LoopInfo after turning guards to branches
SplitBlockAndInsertIfThen doesn't correctly update LoopInfo when called
with Unreachable=true, which is the case when we turn guards to branches
in SimpleLoopUnswitch.

This adds LoopInfo verification before returning from turnGuardIntoBranch.
2023-06-08 18:29:19 +07:00
Florian Hahn
f5f6daf00f
[LV] Extend test coverage for loops with accesses with clamped indexes.
Extend test coverage ahead of upcoming patches.
2023-06-08 12:10:04 +01:00
Florian Hahn
123f807e5b
[LV] Remove UB caused by undef from pr37248.ll (NFC).
Also generate full check lines.
2023-06-08 11:58:58 +01:00
Shivam Gupta
46aba711ab [InstCombine] (icmp eq A, -1) & (icmp eq B, -1) --> (icmp eq (A&B), -1)
This patch add another icmp fold for -1 case.

This fixes https://github.com/llvm/llvm-project/issues/62311,
where we want instcombine to merge all compare intructions together so
later passes like simplifycfg and slpvectorize can better optimize this
chained comparison.

Reviewed By: goldstein.w.n

Differential Revision: https://reviews.llvm.org/D151660
2023-06-08 09:00:05 +05:30
Shivam Gupta
0535da6f11 [InstCombine] Add test case for (icmp eq A, -1) & (icmp eq B, -1) --> (icmp eq (A&B), -1); NFC
Reviewed By: goldstein.w.n

Differential Revision: https://reviews.llvm.org/D151694
2023-06-08 09:00:02 +05:30
Florian Hahn
c10a7772bd
[Matrix] Convert binop operand of dot product to a row vector.
The dot product lowering will use the left operand as row vector.
If the operand is a binary op, convert it to operate on a row vector
instead of a column vector.

Depends on D148428.

Reviewed By: thegameg

Differential Revision: https://reviews.llvm.org/D148429
2023-06-07 20:45:08 +01:00
zhongyunde
df19d87227 [LV] Add option to tune the cost model, NFC
For Neon, the default nonconst stride cost is conservative,
and it is a local variable, which is not convenience to
to tune the loop vectorize.
So I try to use a option, which is similar to SVEGatherOverhead brought in D115143.
Fix https://github.com/llvm/llvm-project/issues/63082.

Reviewed By: dmgreen, fhahn
Differential Revision: https://reviews.llvm.org/D152253
2023-06-07 22:08:29 +08:00
Serguei Katkov
d57ed844fe [CGP] Add test to show the missed case in remove llvm.assume 2023-06-07 17:20:57 +07:00
luxufan
e9ddb584e8 [LoopIdiom] Freeze BitPos if !isGuaranteedNotToBeUndefOrPoison
Fixes: https://github.com/llvm/llvm-project/issues/62873

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D151690
2023-06-07 14:50:22 +08:00
Joshua Cao
cb9f1aadda [ValueTracking] Implied conditions for lshr
`V1 >> V2 u<= V1` for any V1, V2

This works for lshr and any div's that are changed to lshr's

This fixes issues in clang and rustc:
https://github.com/llvm/llvm-project/issues/62441
https://github.com/rust-lang/rust/issues/110971

Reviewed By: goldstein.w.n

Differential Revision: https://reviews.llvm.org/D151541
2023-06-06 21:06:22 -07:00
Joshua Cao
f23b4faaff [InstSimplify] Add tests for shl implied conditions 2023-06-06 21:06:22 -07:00
Chuanqi Xu
84c033d9ba [LICM] [Coroutines] Don't hoist threadlocals within presplit coroutines
Close https://github.com/llvm/llvm-project/issues/63022

This is the following of https://reviews.llvm.org/D135550, which is
discussed in
https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579.
In my imagination, we could fix the issue fundamentally after we
introduces new memory kind thread id. But I am not very sure if we can
fix the issue fundamentally in time.

Besides that, I think the correctness is the most important. So it
should not be bad to land this given it is innocent.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D151774
2023-06-07 10:25:47 +08:00
Chuanqi Xu
eab8c1eb62 [Coroutines] [LICM] Precommit test for D151774
This is required in the review.

Differential Revision: https://reviews.llvm.org/D151774
2023-06-07 10:11:22 +08:00