99 Commits

Author SHA1 Message Date
Jay Foad
85c17e4092
[LLVM] Make more use of IRBuilder::CreateIntrinsic. NFC. (#112706)
Convert many instances of:
  Fn = Intrinsic::getOrInsertDeclaration(...);
  CreateCall(Fn, ...)
to the equivalent CreateIntrinsic call.
2024-10-17 16:20:43 +01:00
Rahul Joshi
fa789dffb1
[NFC] Rename Intrinsic::getDeclaration to getOrInsertDeclaration (#111752)
Rename the function to reflect its correct behavior and to be consistent
with `Module::getOrInsertFunction`. This is also in preparation of
adding a new `Intrinsic::getDeclaration` that will have behavior similar
to `Module::getFunction` (i.e, just lookup, no creation).
2024-10-11 05:26:03 -07:00
Jay Foad
e03f427196
[LLVM] Use {} instead of std::nullopt to initialize empty ArrayRef (#109133)
It is almost always simpler to use {} instead of std::nullopt to
initialize an empty ArrayRef. This patch changes all occurrences I could
find in LLVM itself. In future the ArrayRef(std::nullopt_t) constructor
could be deprecated or removed.
2024-09-19 16:16:38 +01:00
Daniil Fukalov
0da2ba811a
[NFC] Cleanup in ADT and Analysis headers. (#104484)
Remove unused directly includes and forward declarations in ADT and
Analysis headers.
2024-08-17 13:11:18 +02:00
Kazu Hirata
7df9da7d78
[llvm] Construct SmallVector with ArrayRef (NFC) (#101872) 2024-08-04 08:54:23 -07:00
Nikita Popov
9df71d7673
[IR] Add getDataLayout() helpers to Function and GlobalValue (#96919)
Similar to https://github.com/llvm/llvm-project/pull/96902, this adds
`getDataLayout()` helpers to Function and GlobalValue, replacing the
current `getParent()->getDataLayout()` pattern.
2024-06-28 08:36:49 +02:00
Stephen Tozer
d75f9dd1d2 Revert "[IR][NFC] Update IRBuilder to use InsertPosition (#96497)"
Reverts the above commit, as it updates a common header function and
did not update all callsites:

  https://lab.llvm.org/buildbot/#/builders/29/builds/382

This reverts commit 6481dc57612671ebe77fe9c34214fba94e1b3b27.
2024-06-24 18:00:22 +01:00
Stephen Tozer
6481dc5761
[IR][NFC] Update IRBuilder to use InsertPosition (#96497)
Uses the new InsertPosition class (added in #94226) to simplify some of
the IRBuilder interface, and removes the need to pass a BasicBlock
alongside a BasicBlock::iterator, using the fact that we can now get the
parent basic block from the iterator even if it points to the sentinel.
This patch removes the BasicBlock argument from each constructor or call
to setInsertPoint.

This has no functional effect, but later on as we look to remove the
`Instruction *InsertBefore` argument from instruction-creation
(discussed
[here](https://discourse.llvm.org/t/psa-instruction-constructors-changing-to-iterator-only-insertion/77845)),
this will simplify the process by allowing us to deprecate the
InsertPosition constructor directly and catch all the cases where we use
instructions rather than iterators.
2024-06-24 17:27:43 +01:00
Justin Lebar
fab2bb8bfd
Add llvm::min/max_element and use it in llvm/ and mlir/ directories. (#84678)
For some reason this was missing from STLExtras.
2024-03-10 20:00:13 -07:00
Nikita Popov
6c2fbc3a68
[IRBuilder] Add CreatePtrAdd() method (NFC) (#77582)
This abstracts over the common pattern of creating a gep with i8 element
type.
2024-01-12 14:21:21 +01:00
Youngsuk Kim
e5026f0179 [llvm] Remove uses of Type::getPointerTo() (NFC)
Partial progress towards removing in-tree uses of `getPointerTo()`,
by employing the following options:

* Drop the call entirely if the sole purpose of it is to support a no-op
  bitcast (remove the no-op bitcast as well).

* Replace with `PointerType::get()`/`PointerType::getUnqual()`

This is a NFC cleanup effort.

Reviewed By: barannikov88

Differential Revision: https://reviews.llvm.org/D155232
2023-09-22 19:44:38 -04:00
Nikita Popov
f8ffd67dac [HexagonVectorCombine] Remove use of getNonOpaquePointerElementType() (NFC) 2023-07-14 11:31:43 +02:00
Krzysztof Parzyszek
4351060a2f [Hexagon] Properly combine overlapping stores in HVC 2023-06-16 13:29:19 -07:00
Nikita Popov
97b5cc214a [ValueTracking] Remove ORE argument (NFC-ish)
The ORE argument threaded through ValueTracking is used only in a
single, untested place. It is also essentially never passed: The
only places that do so have been added very recently as part of the
KnownFPClass migration, which is vanishingly unlikely to hit this
code path. Remove this effectively dead argument.

Differential Revision: https://reviews.llvm.org/D151562
2023-06-02 09:11:53 +02:00
Krzysztof Parzyszek
96b59b4f06 [Hexagon] Use scalar evolution to calculate pointer difference in HVC 2023-05-27 09:11:09 -07:00
Krzysztof Parzyszek
b9c78deba3 [Hexagon] Add more debugging options and dumps to HVC 2023-05-24 06:06:25 -07:00
Krzysztof Parzyszek
538c141648 [Hexagon] Remap all instructions generated for aligned address/value in HVC
Only the last instruction was remapped before.
2023-05-24 06:06:25 -07:00
Krzysztof Parzyszek
34c7f2ac3d [Hexagon] Fix safety check in moving instructions in HVC::AlignVectors
A prior commit accidentally affected a safety check allowing aliased memory
instructions to be moved across one another.
2023-05-23 07:45:12 -07:00
Krzysztof Parzyszek
f575b7f51c [Hexagon] Clone dependencies instead of moving in HVC
Loads can share dependencies, and moving them for each load separately
can end up placing them in a wrong location. There was already a check
for that, but it wasn't correct.
Instead of trying to find the right location for all moved instructions
at once, create clones for each individual load.
2023-05-19 12:05:26 -07:00
Krzysztof Parzyszek
94a9f6c56c [Hexagon] Add more comments to HexagonVectorCombine.cpp, NFC 2023-05-19 12:05:26 -07:00
Krzysztof Parzyszek
7ce3d9228f [Hexagon] Improve safety of aligned loads/stores in HVC
Generate a predicated variant of the last load/store in a group to
avoid accessing OOB memory. Disable vector alignment on HVX prior
to v62, since v62 does not have predicated vector loads.
2023-05-17 04:33:53 -07:00
Kazu Hirata
5b10fa6e88 [Hexagon] Remove unused declaration getLocation
The unused declaration was introduced without a corresponding function
definition in:

  commit f5d07a05bbd41f827ccfa1bed7bfdfbab2be85dc
  Author: Krzysztof Parzyszek <kparzysz@quicinc.com>
  Date:   Mon Sep 7 14:26:48 2020 -0500
2023-05-16 18:48:38 -07:00
Kazu Hirata
a4a71df87f [Hexagon] Remove unused struct AlignVectors::Segment 2023-05-08 20:23:32 -07:00
Krzysztof Parzyszek
0eac3c5004 [Hexagon] Ensure proper ordering of instructions in HVC::AlignVectors
The shuffle reduction creates a dependency chain. Make sure that the
inputs to the next instruction are placed ahead of the instruction itself.
2023-03-17 08:13:49 -07:00
Krzysztof Parzyszek
5a94669fc6 [Hexagon] Add names to all instructions created in HVC 2023-03-17 08:13:49 -07:00
Krzysztof Parzyszek
7af91965db [Hexagon] Add debug code to HVC::AlignVectors
That and clarify/expand some comments.
2023-03-17 08:13:49 -07:00
Guillaume Chatelet
87b6b347fc Revert D141134 "[NFC] Only expose getXXXSize functions in TypeSize"
The patch should be discussed further.

This reverts commit dd56e1c92b0e6e6be249f2d2dd40894e0417223f.
2023-01-06 15:27:50 +00:00
Guillaume Chatelet
dd56e1c92b [NFC] Only expose getXXXSize functions in TypeSize
Currently 'TypeSize' exposes two functions that serve the same purpose:
 - getFixedSize / getFixedValue
 - getKnownMinSize / getKnownMinValue

source : bf82070ea4/llvm/include/llvm/Support/TypeSize.h (L337-L338)

This patch offers to remove one of the two and stick to a single function in the code base.

Differential Revision: https://reviews.llvm.org/D141134
2023-01-06 15:24:52 +00:00
Fangrui Song
21c4dc7997 std::optional::value => operator*/operator->
value() has undesired exception checking semantics and calls
__throw_bad_optional_access in libc++. Moreover, the API is unavailable without
_LIBCPP_NO_EXCEPTIONS on older Mach-O platforms (see
_LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS).

This fixes clang.
2022-12-17 00:42:05 +00:00
Krzysztof Parzyszek
aaf66cc8a6 [Hexagon] Record original result type in wide multiplication 2022-12-15 07:19:23 -08:00
Krzysztof Parzyszek
1c7c7377cb [Hexagon] Handle rounding beyond low 32 bits 2022-12-14 10:25:34 -08:00
Kazu Hirata
f7dffc28b3 Don't include None.h (NFC)
I've converted all known uses of None to std::nullopt, so we no longer
need to include None.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-10 11:24:26 -08:00
Kazu Hirata
20cde15415 [Target] Use std::nullopt instead of None (NFC)
This patch mechanically replaces None with std::nullopt where the
compiler would warn if None were deprecated.  The intent is to reduce
the amount of manual work required in migrating from Optional to
std::optional.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-02 20:36:06 -08:00
Krzysztof Parzyszek
467432899b MemoryLocation: convert Optional to std::optional 2022-12-01 15:36:20 -08:00
Krzysztof Parzyszek
2191137dff [Hexagon] Check if vector is empty before calling back() 2022-12-01 11:41:47 -08:00
Krzysztof Parzyszek
9b83935672 [Hexagon] Punt on GEPs with different base types in vector alignment 2022-12-01 10:33:48 -08:00
Krzysztof Parzyszek
f8cb97a0f1 [Hexagon] Fix deinterleaving after vmpyh 2022-11-23 13:31:54 -08:00
Krzysztof Parzyszek
ae9356e8c4 [Hexagon] Fix order of operands in V6_vmpyhus
The unsigned operand is second: Vdd32.w = vmpy(Vu32.h,Vv32.uh)
2022-11-23 13:31:54 -08:00
Krzysztof Parzyszek
e27e8e0541 [Hexagon] Use V6_vmpyuhvs for 16-bit mulhu on HVX v69+ 2022-11-22 11:31:22 -08:00
Krzysztof Parzyszek
a03e16a16e [Hexagon] Improve idioms for fixed-point vector multiplication
Make the code more general, restore the ability to generate V6_vmpyhvsrs.
2022-11-12 08:46:27 -08:00
Krzysztof Parzyszek
017186294d [Hexagon] Place aligned loads closer to users
Vector alignment code was grouping all aligned loads together. In some
cases the groups could become quite large causing a lot of spill to be
generated. This will place the loads closer to where they are used,
reducing the register pressure.
2022-11-11 12:04:33 -08:00
Kazu Hirata
17503be455 [Hexagon] Remove HexagonVectorCombine::simplify
This patch fixes:

  llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp:1554:6: warning:
  ‘llvm::Value*
  {anonymous}::HexagonVectorCombine::simplify(llvm::Value*) const’
  defined but not used [-Wunused-function]
2022-10-30 12:56:59 -07:00
Krzysztof Parzyszek
323fb627a5 [Hexagon] Report changes in HvxIdioms pass
It can produce some dead code, which is harmless in the end, but breaks
expensive checks when unreported. This should be fixed eventually, but
it's a low priority.
2022-10-29 11:32:28 -07:00
Krzysztof Parzyszek
9422a8d94c [Hexagon] Break up vectors into HVX-sized chunks in HvxIdioms
This will allow recognizing Q.31 multiplications on vectors that are
multiplies of HVX vectors. At the moment this comes at the expense of
Q.15 multiplications, which now are handled as 32-bit multiplications
with shifts.
In the longer term this will likely be replaced by a different scheme
of "legalizing" vectors, which is necessary for idiom recognition, at
least where using direct HVX instrinsics is desired.
2022-10-29 11:13:28 -07:00
Krzysztof Parzyszek
c4a8f9abac [Hexagon] Fix vector concatenation 2022-10-29 10:46:24 -07:00
Krzysztof Parzyszek
deb197ffa3 [Hexagon] Use helper function introduced in prior commit, NFC 2022-10-22 15:05:38 -07:00
Krzysztof Parzyszek
e5d9ab08c3 [Hexagon] Fix insertion point for pointer difference calculation
HVC::calculatePointerDifference inserts temporary instructions for
simplification, and calulation of known bits. These instructions were
inserted at the end of a basic block (after the terminator), which
caused BB->getTerminator() to return nullptr. This, in turn, caused
a crash when a PHI instruction was examined in computeKnownBits.
2022-10-19 14:23:39 -07:00
Krzysztof Parzyszek
fb063ea2ea [Hexagon] Clean up leftover instructions in HvxIdioms
Quick and dirty fix, because this is causing one builder to fail.
2022-10-14 16:45:03 -07:00
Krzysztof Parzyszek
6cb2a02a38 [Hexagon] Report if changes were made in HvxIdioms pass
This should fix
```
Pass modifies its input and doesn't report it: Hexagon Vector Combine
Pass modifies its input and doesn't report it UNREACHABLE executed at
[...hecks-debian/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1436!
```
2022-10-14 15:46:33 -07:00
Krzysztof Parzyszek
361a27c155 [Hexagon] Recognize idioms for fixed-point vector multiplication
Recognize Q.15*Q.15 and Q.31*Q.31, with and without rounding.
2022-10-14 15:22:25 -07:00