[llvm-branch-commits] [not] Update disable-symbolization.test to work with internal shell (PR #157236)
https://github.com/boomanaiden154 updated https://github.com/llvm/llvm-project/pull/157236 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] release/21.x: [RISCV] Support PreserveMost calling convention (#148214) (PR #158402)
wangpc-pp wrote: > @wangpc-pp how can we continue? The failure seems not a real failure. You should wait for @tru, he will merge this if there is no issue. https://github.com/llvm/llvm-project/pull/158402 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [LoongArch] Add generation support for `[x]{vandn/vorn}.v` (PR #158526)
https://github.com/heiher approved this pull request. LGTM. https://github.com/llvm/llvm-project/pull/158526 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [Clang] Make rewrite-includes-bom.c work with internal shell (PR #158463)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Aiden Grossman (boomanaiden154) Changes This test was using $'
[llvm-branch-commits] [Clang] Enable lit internal shell by default (PR #158465)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/158465 Now that all of the clang tests have been verified (and adjusted when necessary) to work with lit's internal shell, we can enable it by default, which this patch does. This should make check-clang 10-15% faster in addition to providing richer feedback on test failures. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [Clang] Enable lit internal shell by default (PR #158465)
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: Aiden Grossman (boomanaiden154)
Changes
Now that all of the clang tests have been verified (and adjusted when
necessary) to work with lit's internal shell, we can enable it by
default, which this patch does.
This should make check-clang 10-15% faster in addition to providing
richer feedback on test failures.
---
Full diff: https://github.com/llvm/llvm-project/pull/158465.diff
1 Files Affected:
- (modified) clang/test/lit.cfg.py (+12-1)
``diff
diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index d34319131ab6d..09c9311c4d362 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -18,11 +18,22 @@
# name: The name of this test suite.
config.name = "Clang"
+# TODO: Consolidate the logic for turning on the internal shell by default for
all LLVM test suites.
+# See https://github.com/llvm/llvm-project/issues/106636 for more details.
+#
+# We prefer the lit internal shell which provides a better user experience on
failures
+# and is faster unless the user explicitly disables it with
LIT_USE_INTERNAL_SHELL=0
+# env var.
+use_lit_shell = True
+lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
+if lit_shell_env:
+use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
+
# testFormat: The test format to use to interpret tests.
#
# For now we require '&&' between commands, until they get globally killed and
# the test runner updated.
-config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
+config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)
# suffixes: A list of file extensions to treat as test files.
config.suffixes = [
``
https://github.com/llvm/llvm-project/pull/158465
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lit] Add support for deleting symlinks to directories without -r (PR #158464)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/158464 Before this change, rm would assume that a symlink to a directory was actually a directory and require the recursive flag to be passed, differing from other shells. Given the change in lit is about the same length as the test change would be (minus tests), I think it makes sense to just support this in the internal shell. ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lit] Add support for deleting symlinks to directories without -r (PR #158464)
llvmbot wrote:
@llvm/pr-subscribers-testing-tools
Author: Aiden Grossman (boomanaiden154)
Changes
Before this change, rm would assume that a symlink to a directory was
actually a directory and require the recursive flag to be passed,
differing from other shells. Given the change in lit is about the same
length as the test change would be (minus tests), I think it makes sense
to just support this in the internal shell.
---
Full diff: https://github.com/llvm/llvm-project/pull/158464.diff
4 Files Affected:
- (modified) llvm/utils/lit/lit/TestRunner.py (+3-1)
- (added) llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/lit.cfg (+7)
- (added) llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/rm-symlink-dir.txt
(+5)
- (added) llvm/utils/lit/tests/shtest-shell-symlinks.py (+9)
``diff
diff --git a/llvm/utils/lit/lit/TestRunner.py b/llvm/utils/lit/lit/TestRunner.py
index 5daa8887e4c80..babc5361fa16b 100644
--- a/llvm/utils/lit/lit/TestRunner.py
+++ b/llvm/utils/lit/lit/TestRunner.py
@@ -516,7 +516,9 @@ def on_rm_error(func, path, exc_info):
if force and not os.path.exists(path):
continue
try:
-if os.path.isdir(path):
+if os.path.islink(path):
+os.remove(path)
+elif os.path.isdir(path):
if not recursive:
stderr.write("Error: %s is a directory\n" % path)
exitCode = 1
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/lit.cfg
b/llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/lit.cfg
new file mode 100644
index 0..eab06f08b688c
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/lit.cfg
@@ -0,0 +1,7 @@
+import lit.formats
+
+config.name = "shtest-shell"
+config.suffixes = [".txt"]
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
diff --git
a/llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/rm-symlink-dir.txt
b/llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/rm-symlink-dir.txt
new file mode 100644
index 0..a44a07c13e4ae
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell-symlinks/rm-symlink-dir.txt
@@ -0,0 +1,5 @@
+# Check that we can delete a symlink to a folder without -r
+#
+# RUN: mkdir %t.dir
+# RUN: ln -s %t.dir %t.symlink
+# RUN: rm %t.symlink
diff --git a/llvm/utils/lit/tests/shtest-shell-symlinks.py
b/llvm/utils/lit/tests/shtest-shell-symlinks.py
new file mode 100644
index 0..cfd72a01b6d94
--- /dev/null
+++ b/llvm/utils/lit/tests/shtest-shell-symlinks.py
@@ -0,0 +1,9 @@
+# Check that the internal shell builtins correctly handle cases involving
+# symlinks.
+
+# REQUIRES: symlinks
+# RUN: echo test
+# RUN: %{lit} -v %{inputs}/shtest-shell-symlinks | FileCheck %s
+
+# CHECK: -- Testing: 1 test{{.*}}
+# CHECK: PASS: shtest-shell :: rm-symlink-dir.txt
``
https://github.com/llvm/llvm-project/pull/158464
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [AMDGPU][Attributor] Add `AAAMDGPUClusterDims` (PR #158076)
shiltian wrote: ### Merge activity * **Sep 12, 11:16 PM UTC**: A user started a stack merge that includes this pull request via [Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/158076). https://github.com/llvm/llvm-project/pull/158076 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [NFC][mlir][ptr] Clarify pointer dialect semantics (PR #158484)
https://github.com/joker-eph approved this pull request. https://github.com/llvm/llvm-project/pull/158484 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [flang] [llvm] [mlir] [Flang][OpenMP][MLIR] Initial declare target to for variables implementation (PR #119589)
agozillon wrote: Small ping for some reviewer attention next week if possible please :-) https://github.com/llvm/llvm-project/pull/119589 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [NFC][mlir][ptr] Clarify pointer dialect semantics (PR #158484)
llvmbot wrote:
@llvm/pr-subscribers-mlir
Author: Fabian Mora (fabianmcg)
Changes
This patch adds the following description to the pointer dialect:
```
The pointer dialect provides types and operations for representing and
interacting with pointer values in MLIR, such as loading and storing values
from/to memory addresses.
The dialect's main type is an opaque pointer (`ptr`) that can be
parameterized by a memory space. This type represents a handle to an object
in memory, or target-dependent values like `nullptr`. Further, the dialect
assumes that the minimum addressable unit by a pointer is a byte. However,
the dialect does not make assumptions about the size of a byte, which is
considered a target-specific property.
```
---
Full diff: https://github.com/llvm/llvm-project/pull/158484.diff
1 Files Affected:
- (modified) mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td (+12)
``diff
diff --git a/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td
b/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td
index 7407d74ce3a87..c98df5775195a 100644
--- a/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td
+++ b/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td
@@ -21,6 +21,18 @@ include "mlir/IR/OpBase.td"
def Ptr_Dialect : Dialect {
let name = "ptr";
let summary = "Pointer dialect";
+ let description = [{
+The pointer dialect provides types and operations for representing and
+interacting with pointer values in MLIR, such as loading and storing values
+from/to memory addresses.
+
+The dialect's main type is an opaque pointer (`ptr`) that can be
+parameterized by a memory space. This type represents a handle to an object
+in memory, or target-dependent values like `nullptr`. Further, the dialect
+assumes that the minimum addressable unit by a pointer is a byte. However,
+the dialect does not make assumptions about the size of a byte, which is
+considered a target-specific property.
+ }];
let cppNamespace = "::mlir::ptr";
let useDefaultTypePrinterParser = 1;
let useDefaultAttributePrinterParser = 1;
``
https://github.com/llvm/llvm-project/pull/158484
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [NFC][mlir][ptr] Clarify pointer dialect semantics (PR #158484)
github-actions[bot] wrote: ⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off [Keep my email addresses private](https://github.com/settings/emails) setting in your account. See [LLVM Developer Policy](https://llvm.org/docs/DeveloperPolicy.html#email-addresses) and [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) for more information. https://github.com/llvm/llvm-project/pull/158484 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] [mlir][ptr] Add `ptr.ptr_diff` operation (PR #157354)
https://github.com/fabianmcg updated https://github.com/llvm/llvm-project/pull/157354 >From 4015e6f30fb89b5c0a4bb60ffdc8b3db51b2edc1 Mon Sep 17 00:00:00 2001 From: Fabian Mora <[email protected]> Date: Sun, 7 Sep 2025 17:33:04 + Subject: [PATCH 1/2] [mlir][ptr] Add `ptr.ptr_diff` op Thi patch introduces the `ptr.ptr_diff` operation for computing pointer differences. The semantics of the operation are given by: ``` The `ptr_diff` operation computes the difference between two pointers, returning an integer or index value representing the number of bytes between them. This difference is always computed using signed arithmetic. The operation supports both scalar and shaped types with value semantics: - When both operands are scalar: produces a single difference value - When both are shaped: performs element-wise subtraction, shapes must be the same The operation also supports the following flags: - `none`: No flags are set. - `nuw`: No Unsigned Wrap, if the subtraction causes an unsigned overflow, the result is a poison value. - `nsw`: No Signed Wrap, if the subtraction causes a signed overflow, the result is a poison value. NOTE: The pointer difference is calculated using an integer type specified by the data layout. The final result will be sign-extended or truncated to fit the result type as necessary. ``` This patch also adds translation to LLVM IR hooks for the `ptr_diff` op. This translation uses the `ptrtoaddr` builder to compute only index bits difference. Example: ```mlir llvm.func @ptr_diff_vector_i32(%ptrs1: vector<8x!ptr.ptr<#llvm.address_space<0>>>, %ptrs2: vector<8x!ptr.ptr<#llvm.address_space<0>>>) -> vector<8xi32> { %diffs = ptr.ptr_diff %ptrs1, %ptrs2 : vector<8x!ptr.ptr<#llvm.address_space<0>>> -> vector<8xi32> llvm.return %diffs : vector<8xi32> } ``` Translation to LLVM IR: ```llvm define <8 x i32> @ptr_diff_vector_i32(<8 x ptr> %0, <8 x ptr> %1) { %3 = ptrtoint <8 x ptr> %0 to <8 x i64> %4 = ptrtoint <8 x ptr> %1 to <8 x i64> %5 = sub <8 x i64> %3, %4 %6 = trunc <8 x i64> %5 to <8 x i32> ret <8 x i32> %6 } ``` --- mlir/include/mlir/Dialect/Ptr/IR/PtrEnums.td | 10 ++ mlir/include/mlir/Dialect/Ptr/IR/PtrOps.td| 57 +++ mlir/lib/Dialect/Ptr/IR/PtrDialect.cpp| 34 +++ .../Dialect/Ptr/PtrToLLVMIRTranslation.cpp| 37 +++ mlir/test/Dialect/Ptr/invalid.mlir| 8 ++ mlir/test/Dialect/Ptr/ops.mlir| 28 ++ mlir/test/Target/LLVMIR/ptr.mlir | 96 +++ 7 files changed, 270 insertions(+) diff --git a/mlir/include/mlir/Dialect/Ptr/IR/PtrEnums.td b/mlir/include/mlir/Dialect/Ptr/IR/PtrEnums.td index c169f48e573d0..c97bd04d32896 100644 --- a/mlir/include/mlir/Dialect/Ptr/IR/PtrEnums.td +++ b/mlir/include/mlir/Dialect/Ptr/IR/PtrEnums.td @@ -79,4 +79,14 @@ def Ptr_PtrAddFlags : I32Enum<"PtrAddFlags", "Pointer add flags", [ let cppNamespace = "::mlir::ptr"; } +//===--===// +// Ptr diff flags enum properties. +//===--===// + +def Ptr_PtrDiffFlags : I8BitEnum<"PtrDiffFlags", "Pointer difference flags", [ +I8BitEnumCase<"none", 0>, I8BitEnumCase<"nuw", 1>, I8BitEnumCase<"nsw", 2> + ]> { + let cppNamespace = "::mlir::ptr"; +} + #endif // PTR_ENUMS diff --git a/mlir/include/mlir/Dialect/Ptr/IR/PtrOps.td b/mlir/include/mlir/Dialect/Ptr/IR/PtrOps.td index 468a3004d5c62..7735210e809e3 100644 --- a/mlir/include/mlir/Dialect/Ptr/IR/PtrOps.td +++ b/mlir/include/mlir/Dialect/Ptr/IR/PtrOps.td @@ -415,6 +415,63 @@ def Ptr_PtrAddOp : Pointer_Op<"ptr_add", [ }]; } +//===--===// +// PtrDiffOp +//===--===// + +def Ptr_PtrDiffOp : Pointer_Op<"ptr_diff", [ +Pure, AllTypesMatch<["lhs", "rhs"]>, SameOperandsAndResultShape + ]> { + let summary = "Pointer difference operation"; + let description = [{ +The `ptr_diff` operation computes the difference between two pointers, +returning an integer or index value representing the number of bytes +between them. This difference is always computed using signed arithmetic. + +The operation supports both scalar and shaped types with value semantics: +- When both operands are scalar: produces a single difference value +- When both are shaped: performs element-wise subtraction, + shapes must be the same + +The operation also supports the following flags: +- `none`: No flags are set. +- `nuw`: No Unsigned Wrap, if the subtraction causes an unsigned overflow, + the result is a poison value. +- `nsw`: No Signed Wrap, if the subtraction causes a signed overflow, the + result is a poison value. + +NOTE: The pointer difference is calculated using an integer type specified +by the data layout.
[llvm-branch-commits] [mlir] [NFC][mlir][ptr] Clarify pointer dialect semantics (PR #158484)
https://github.com/fabianmcg created https://github.com/llvm/llvm-project/pull/158484 This patch adds the following description to the pointer dialect: ``` The pointer dialect provides types and operations for representing and interacting with pointer values in MLIR, such as loading and storing values from/to memory addresses. The dialect's main type is an opaque pointer (`ptr`) that can be parameterized by a memory space. This type represents a handle to an object in memory, or target-dependent values like `nullptr`. Further, the dialect assumes that the minimum addressable unit by a pointer is a byte. However, the dialect does not make assumptions about the size of a byte, which is considered a target-specific property. ``` >From 120da3c559522ae1173a35953d92a47e0e4b5421 Mon Sep 17 00:00:00 2001 From: Fabian Mora <[email protected]> Date: Sun, 14 Sep 2025 14:17:38 + Subject: [PATCH] [NFC][mlir][ptr] Clarify pointer dialect semantics This patch adds the following description to the pointer dialect: ``` The pointer dialect provides types and operations for representing and interacting with pointer values in MLIR, such as loading and storing values from/to memory addresses. The dialect's main type is an opaque pointer (`ptr`) that can be parameterized by a memory space. This type represents a handle to an object in memory, or target-dependent values like `nullptr`. Further, the dialect assumes that the minimum addressable unit by a pointer is a byte. However, the dialect does not make assumptions about the size of a byte, which is considered a target-specific property. ``` --- mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td | 12 1 file changed, 12 insertions(+) diff --git a/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td b/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td index 7407d74ce3a87..c98df5775195a 100644 --- a/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td +++ b/mlir/include/mlir/Dialect/Ptr/IR/PtrDialect.td @@ -21,6 +21,18 @@ include "mlir/IR/OpBase.td" def Ptr_Dialect : Dialect { let name = "ptr"; let summary = "Pointer dialect"; + let description = [{ +The pointer dialect provides types and operations for representing and +interacting with pointer values in MLIR, such as loading and storing values +from/to memory addresses. + +The dialect's main type is an opaque pointer (`ptr`) that can be +parameterized by a memory space. This type represents a handle to an object +in memory, or target-dependent values like `nullptr`. Further, the dialect +assumes that the minimum addressable unit by a pointer is a byte. However, +the dialect does not make assumptions about the size of a byte, which is +considered a target-specific property. + }]; let cppNamespace = "::mlir::ptr"; let useDefaultTypePrinterParser = 1; let useDefaultAttributePrinterParser = 1; ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [Clang] Make rewrite-includes-bom.c work with internal shell (PR #158463)
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/158463 This test was using $'https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] b5516da - [PGO][test] Ensure test input is writeable after copying. (#158356)
Author: jtstogel
Date: 2025-09-12T15:49:39-05:00
New Revision: b5516dad6e18db91858449bfa96a5e1271568037
URL:
https://github.com/llvm/llvm-project/commit/b5516dad6e18db91858449bfa96a5e1271568037
DIFF:
https://github.com/llvm/llvm-project/commit/b5516dad6e18db91858449bfa96a5e1271568037.diff
LOG: [PGO][test] Ensure test input is writeable after copying. (#158356)
This test errors when trying to append to the `%t` file when run in an
environment where the source tree is mounted read-only, since `cp`
preserves the read-only file permission.
Added:
Modified:
llvm/test/Verifier/llvm.loop.estimated_trip_count.ll
Removed:
diff --git a/llvm/test/Verifier/llvm.loop.estimated_trip_count.ll
b/llvm/test/Verifier/llvm.loop.estimated_trip_count.ll
index 3c0bc8a39ebeb..b1e456f5b0ad6 100644
--- a/llvm/test/Verifier/llvm.loop.estimated_trip_count.ll
+++ b/llvm/test/Verifier/llvm.loop.estimated_trip_count.ll
@@ -26,36 +26,43 @@ exit:
; No value.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count"}' >> %t
; RUN: not %{RUN} TOO-FEW
; i16 value.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count", i16 5}' >> %t
; RUN: %{RUN} GOOD
; i32 value.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count", i32 5}' >> %t
; RUN: %{RUN} GOOD
; i64 value.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count", i64 5}' >> %t
; RUN: not %{RUN} BAD-VALUE
; MDString value.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count", !"5"}' >> %t
; RUN: not %{RUN} BAD-VALUE
; MDNode value.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count", !2}' >> %t
; RUN: echo '!2 = !{i32 5}' >> %t
; RUN: not %{RUN} BAD-VALUE
; Too many values.
; RUN: cp %s %t
+; RUN: chmod u+w %t
; RUN: echo '!1 = !{!"llvm.loop.estimated_trip_count", i32 5, i32 5}' >> %t
; RUN: not %{RUN} TOO-MANY
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [mlir] 86bcd1c - [mlir][Intrange] Fix materializing ShapedType constant values (#158359)
Author: Jeff Niu
Date: 2025-09-12T13:53:32-07:00
New Revision: 86bcd1c2b256cd6aa5e65e1a54b63f929d616464
URL:
https://github.com/llvm/llvm-project/commit/86bcd1c2b256cd6aa5e65e1a54b63f929d616464
DIFF:
https://github.com/llvm/llvm-project/commit/86bcd1c2b256cd6aa5e65e1a54b63f929d616464.diff
LOG: [mlir][Intrange] Fix materializing ShapedType constant values (#158359)
When materializing integer ranges of splat tensors or vector as
constants, they should use DenseElementsAttr of the shaped type, not
IntegerAttrs of the element types, since this can violate the invariants
of tensor/vector ops.
Co-authored-by: Jeff Niu
Added:
Modified:
mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp
mlir/test/Dialect/Arith/int-range-opts.mlir
Removed:
diff --git a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
index e79f6a8aec1cf..70b56ca77b2da 100644
--- a/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
+++ b/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp
@@ -26,6 +26,7 @@
#include "mlir/Interfaces/ControlFlowInterfaces.h"
#include "mlir/Interfaces/InferIntRangeInterface.h"
#include "mlir/Interfaces/LoopLikeInterface.h"
+#include "mlir/Support/DebugStringHelper.h"
#include "mlir/Support/LLVM.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Casting.h"
@@ -76,9 +77,17 @@ void IntegerValueRangeLattice::onUpdate(DataFlowSolver
*solver) const {
else
dialect = value.getParentBlock()->getParentOp()->getDialect();
- Type type = getElementTypeOrSelf(value);
- solver->propagateIfChanged(
- cv, cv->join(ConstantValue(IntegerAttr::get(type, *constant), dialect)));
+ Attribute cstAttr;
+ if (isa(value.getType())) {
+cstAttr = IntegerAttr::get(value.getType(), *constant);
+ } else if (auto shapedTy = dyn_cast(value.getType())) {
+cstAttr = SplatElementsAttr::get(shapedTy, *constant);
+ } else {
+llvm::report_fatal_error(
+Twine("FIXME: Don't know how to create a constant for this type: ") +
+mlir::debugString(value.getType()));
+ }
+ solver->propagateIfChanged(cv, cv->join(ConstantValue(cstAttr, dialect)));
}
LogicalResult IntegerRangeAnalysis::visitOperation(
diff --git a/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp
b/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp
index 777ff0ecaa314..2017905587b26 100644
--- a/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/IntRangeOptimizations.cpp
@@ -8,6 +8,7 @@
#include
+#include "mlir/Analysis/DataFlow/ConstantPropagationAnalysis.h"
#include "mlir/Analysis/DataFlowFramework.h"
#include "mlir/Dialect/Arith/Transforms/Passes.h"
@@ -485,6 +486,7 @@ struct IntRangeOptimizationsPass final
MLIRContext *ctx = op->getContext();
DataFlowSolver solver;
solver.load();
+solver.load();
solver.load();
if (failed(solver.initializeAndRun(op)))
return signalPassFailure();
diff --git a/mlir/test/Dialect/Arith/int-range-opts.mlir
b/mlir/test/Dialect/Arith/int-range-opts.mlir
index ea5969a100258..e6e48d30cece5 100644
--- a/mlir/test/Dialect/Arith/int-range-opts.mlir
+++ b/mlir/test/Dialect/Arith/int-range-opts.mlir
@@ -132,3 +132,19 @@ func.func @wraps() -> i8 {
%mod = arith.remsi %val, %c64 : i8
return %mod : i8
}
+
+// -
+
+// CHECK-LABEL: @analysis_crash
+func.func @analysis_crash(%arg0: i32, %arg1: tensor<128xi1>) ->
tensor<128xi64> {
+ %c0_i32 = arith.constant 0 : i32
+ %cst = arith.constant dense<-1> : tensor<128xi32>
+ %splat = tensor.splat %arg0 : tensor<128xi32>
+ %0 = scf.for %arg2 = %c0_i32 to %arg0 step %arg0 iter_args(%arg3 = %splat)
-> (tensor<128xi32>) : i32 {
+scf.yield %arg3 : tensor<128xi32>
+ }
+ %1 = arith.select %arg1, %0#0, %cst : tensor<128xi1>, tensor<128xi32>
+ // Make sure the analysis doesn't crash when materializing the range as a
tensor constant.
+ %2 = arith.extsi %1 : tensor<128xi32> to tensor<128xi64>
+ return %2 : tensor<128xi64>
+}
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/21.x: [clang-format] Handle C digit separators (#158418) (PR #158512)
https://github.com/llvmbot milestoned https://github.com/llvm/llvm-project/pull/158512 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/21.x: [clang-format] Handle C digit separators (#158418) (PR #158512)
llvmbot wrote: @HazardyKnusperkeks What do you think about merging this PR to the release branch? https://github.com/llvm/llvm-project/pull/158512 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/21.x: [clang-format] Handle C digit separators (#158418) (PR #158512)
https://github.com/llvmbot created
https://github.com/llvm/llvm-project/pull/158512
Backport 30f4781eef567b99214e02137a57c7ac91279a48
Requested by: @owenca
>From 45684d48d66be8e36b5df7bc99d2833ce58b2a97 Mon Sep 17 00:00:00 2001
From: owenca
Date: Sun, 14 Sep 2025 14:20:59 -0700
Subject: [PATCH] [clang-format] Handle C digit separators (#158418)
Fixes #158413
(cherry picked from commit 30f4781eef567b99214e02137a57c7ac91279a48)
---
clang/lib/Format/Format.cpp | 1 +
clang/unittests/Format/TokenAnnotatorTest.cpp | 7 +++
2 files changed, 8 insertions(+)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 513fcfcd41258..161a6c4b47e7f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -4043,6 +4043,7 @@ LangOptions getFormattingLangOpts(const FormatStyle
&Style) {
switch (Style.Language) {
case FormatStyle::LK_C:
LangOpts.C11 = 1;
+LangOpts.C23 = 1;
break;
case FormatStyle::LK_Cpp:
case FormatStyle::LK_ObjC:
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index af94841c820a4..0a3dc946e8c1c 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -4097,6 +4097,13 @@ TEST_F(TokenAnnotatorTest, UTF8StringLiteral) {
EXPECT_TOKEN(Tokens[1], tok::utf8_string_literal, TT_Unknown);
}
+TEST_F(TokenAnnotatorTest, C23DigitSeparator) {
+ auto Tokens = annotate("return 1'000;", getLLVMStyle(FormatStyle::LK_C));
+ ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+ EXPECT_EQ(Tokens[1]->TokenText, "1'000");
+ EXPECT_TOKEN(Tokens[2], tok::semi, TT_Unknown);
+}
+
TEST_F(TokenAnnotatorTest, IdentifierPackage) {
auto Tokens = annotate("auto package;");
ASSERT_EQ(Tokens.size(), 4u) << Tokens;
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [clang] release/21.x: [clang-format] Handle C digit separators (#158418) (PR #158512)
llvmbot wrote:
@llvm/pr-subscribers-clang-format
Author: None (llvmbot)
Changes
Backport 30f4781eef567b99214e02137a57c7ac91279a48
Requested by: @owenca
---
Full diff: https://github.com/llvm/llvm-project/pull/158512.diff
2 Files Affected:
- (modified) clang/lib/Format/Format.cpp (+1)
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+7)
``diff
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 513fcfcd41258..161a6c4b47e7f 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -4043,6 +4043,7 @@ LangOptions getFormattingLangOpts(const FormatStyle
&Style) {
switch (Style.Language) {
case FormatStyle::LK_C:
LangOpts.C11 = 1;
+LangOpts.C23 = 1;
break;
case FormatStyle::LK_Cpp:
case FormatStyle::LK_ObjC:
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index af94841c820a4..0a3dc946e8c1c 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -4097,6 +4097,13 @@ TEST_F(TokenAnnotatorTest, UTF8StringLiteral) {
EXPECT_TOKEN(Tokens[1], tok::utf8_string_literal, TT_Unknown);
}
+TEST_F(TokenAnnotatorTest, C23DigitSeparator) {
+ auto Tokens = annotate("return 1'000;", getLLVMStyle(FormatStyle::LK_C));
+ ASSERT_EQ(Tokens.size(), 4u) << Tokens;
+ EXPECT_EQ(Tokens[1]->TokenText, "1'000");
+ EXPECT_TOKEN(Tokens[2], tok::semi, TT_Unknown);
+}
+
TEST_F(TokenAnnotatorTest, IdentifierPackage) {
auto Tokens = annotate("auto package;");
ASSERT_EQ(Tokens.size(), 4u) << Tokens;
``
https://github.com/llvm/llvm-project/pull/158512
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] CodeGen: Introduce MachineFunction::getPreferredAlignment(). (PR #158368)
llvmbot wrote:
@llvm/pr-subscribers-backend-x86
Author: Peter Collingbourne (pcc)
Changes
MachineFunction can now be queried for the preferred alignment which
comes from the function attributes (optsize, minsize, prefalign) and
TargetLowering.
Part of this RFC:
https://discourse.llvm.org/t/rfc-enhancing-function-alignment-attributes/88019
---
Full diff: https://github.com/llvm/llvm-project/pull/158368.diff
6 Files Affected:
- (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+2)
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+1-1)
- (modified) llvm/lib/CodeGen/AsmPrinter/WinException.cpp (+2-2)
- (modified) llvm/lib/CodeGen/MachineFunction.cpp (+13-5)
- (modified) llvm/lib/Target/X86/X86AsmPrinter.cpp (+1-1)
- (modified) llvm/test/CodeGen/PowerPC/alloca-crspill.ll (+1-1)
``diff
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h
b/llvm/include/llvm/CodeGen/MachineFunction.h
index ef783f276b7d4..a454ad02df23d 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -818,6 +818,8 @@ class LLVM_ABI MachineFunction {
Alignment = A;
}
+ Align getPreferredAlignment() const;
+
/// exposesReturnsTwice - Returns true if the function calls setjmp or
/// any other similar functions with attribute "returns twice" without
/// having the attribute itself.
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index cd14a4f57f760..7b08098225427 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -978,7 +978,7 @@ void AsmPrinter::emitFunctionHeader() {
emitLinkage(&F, CurrentFnSym);
if (MAI->hasFunctionAlignment())
-emitAlignment(MF->getAlignment(), &F);
+emitAlignment(MF->getPreferredAlignment(), &F);
if (MAI->hasDotTypeDotSizeDirective())
OutStreamer->emitSymbolAttribute(CurrentFnSym, MCSA_ELF_TypeFunction);
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
index 13fd270ec7410..90d8196ffb82a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/WinException.cpp
@@ -204,8 +204,8 @@ void WinException::beginFunclet(const MachineBasicBlock
&MBB,
// We want our funclet's entry point to be aligned such that no nops will
be
// present after the label.
-Asm->emitAlignment(std::max(Asm->MF->getAlignment(), MBB.getAlignment()),
- &F);
+Asm->emitAlignment(
+std::max(Asm->MF->getPreferredAlignment(), MBB.getAlignment()), &F);
// Now that we've emitted the alignment directive, point at our funclet.
Asm->OutStreamer->emitLabel(Sym);
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp
b/llvm/lib/CodeGen/MachineFunction.cpp
index 224231cb90fe2..478a7ccbdfe41 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -211,11 +211,6 @@ void MachineFunction::init() {
ConstantPool = new (Allocator) MachineConstantPool(getDataLayout());
Alignment = STI.getTargetLowering()->getMinFunctionAlignment();
- // FIXME: Shouldn't use pref alignment if explicit alignment is set on F.
- if (!F.hasOptSize())
-Alignment = std::max(Alignment,
- STI.getTargetLowering()->getPrefFunctionAlignment());
-
// -fsanitize=function and -fsanitize=kcfi instrument indirect function calls
// to load a type hash before the function label. Ensure functions are
aligned
// by a least 4 to avoid unaligned access, which is especially important for
@@ -330,6 +325,19 @@ bool MachineFunction::shouldSplitStack() const {
return getFunction().hasFnAttribute("split-stack");
}
+Align MachineFunction::getPreferredAlignment() const {
+ Align PrefAlignment;
+
+ if (MaybeAlign A = F.getPreferredAlignment())
+PrefAlignment = *A;
+ else if (!F.hasOptSize())
+PrefAlignment = STI.getTargetLowering()->getPrefFunctionAlignment();
+ else
+PrefAlignment = Align(1);
+
+ return std::max(PrefAlignment, getAlignment());
+}
+
[[nodiscard]] unsigned
MachineFunction::addFrameInst(const MCCFIInstruction &Inst) {
FrameInstructions.push_back(Inst);
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp
b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index a7734e9200a19..b66ea8e3b440e 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -155,7 +155,7 @@ void X86AsmPrinter::EmitKCFITypePadding(const
MachineFunction &MF,
if (HasType)
PrefixBytes += 5;
- emitNops(offsetToAlignment(PrefixBytes, MF.getAlignment()));
+ emitNops(offsetToAlignment(PrefixBytes, MF.getPreferredAlignment()));
}
/// emitKCFITypeId - Emit the KCFI type information in architecture specific
diff --git a/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
b/llvm/test/CodeGen/PowerPC/alloca-crspill.ll
index cbcfd9a6a0dab..bd88b5d89202d 100644
--- a/llvm/test/CodeGen/PowerP
[llvm-branch-commits] [llvm] AMDGPU/UniformityAnalysis: fix G_ZEXTLOAD and G_SEXTLOAD (PR #157845)
https://github.com/petar-avramovic ready_for_review https://github.com/llvm/llvm-project/pull/157845 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [libcxx] release/21.x: [libc++][AIX] Fixup problems with ABI list checking (#155643) (PR #156502)
https://github.com/tru updated https://github.com/llvm/llvm-project/pull/156502
>From 7a077a1b312b66055643e05d88795c5b1f329874 Mon Sep 17 00:00:00 2001
From: David Tenty
Date: Wed, 27 Aug 2025 18:28:26 -0400
Subject: [PATCH] [libc++][AIX] Fixup problems with ABI list checking (#155643)
There are some problems with our ABI list checking exposed by recent
compiler/cmake upgrades.
- For symcheck, there are typos in how XCOFF magic are defined, we
intended the second two digits to be a hex value, but our syntax doesn't
say that. Thus this will never match a valid XCOFF file.
- AIX triples can have version numbers. Those need to be discarded when
looking for an libc++ ABI list, like we do for other targets.
(cherry picked from commit b8456e2a9698aa927d7b3f9c38213f3219aa0498)
---
libcxx/lib/abi/CMakeLists.txt | 3 +++
libcxx/utils/libcxx/sym_check/util.py | 2 +-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/libcxx/lib/abi/CMakeLists.txt b/libcxx/lib/abi/CMakeLists.txt
index 7c08bd06c50b2..8f277aad2dcd5 100644
--- a/libcxx/lib/abi/CMakeLists.txt
+++ b/libcxx/lib/abi/CMakeLists.txt
@@ -16,6 +16,9 @@ function(cxx_abi_list_identifier result triple abi_library
abi_version unstable
elseif("${triple}" MATCHES "freebsd")
# Ignore the major and minor versions of freebsd targets.
string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd" triple "${triple}")
+ elseif("${triple}" MATCHES "aix")
+# Ignore the V.R.M.F version string of aix targets.
+string(REGEX REPLACE "aix[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+" "aix" triple
"${triple}")
endif()
list(APPEND abi_properties "${triple}")
list(APPEND abi_properties "${abi_library}")
diff --git a/libcxx/utils/libcxx/sym_check/util.py
b/libcxx/utils/libcxx/sym_check/util.py
index fc7ba4244ab5a..dbc886f29ddea 100644
--- a/libcxx/utils/libcxx/sym_check/util.py
+++ b/libcxx/utils/libcxx/sym_check/util.py
@@ -95,7 +95,7 @@ def is_xcoff_or_big_ar(filename):
with open(filename, "rb") as f:
magic_bytes = f.read(7)
return (
-magic_bytes[:4] in [b"\x01DF", b"\x01F7"] # XCOFF32 # XCOFF64
+magic_bytes[:2] in [b"\x01\xDF", b"\x01\xF7"] # XCOFF32 # XCOFF64
or magic_bytes == b""
)
___
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [lit] Add support for deleting symlinks to directories without -r (PR #158464)
https://github.com/cmtice approved this pull request. https://github.com/llvm/llvm-project/pull/158464 ___ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [LoongArch] Add generation support for `[x]{vandn/vorn}.v` (PR #158526)
llvmbot wrote:
@llvm/pr-subscribers-backend-loongarch
Author: ZhaoQi (zhaoqi5)
Changes
---
Full diff: https://github.com/llvm/llvm-project/pull/158526.diff
8 Files Affected:
- (modified) llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td (+8)
- (modified) llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td (+8)
- (modified) llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll (+1-3)
- (modified) llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll (+4-11)
- (modified) llvm/test/CodeGen/LoongArch/lasx/ir-instruction/orn.ll (+12-19)
- (modified) llvm/test/CodeGen/LoongArch/lsx/intrinsic-bitclr.ll (+1-3)
- (modified) llvm/test/CodeGen/LoongArch/lsx/ir-instruction/andn.ll (+4-11)
- (modified) llvm/test/CodeGen/LoongArch/lsx/ir-instruction/orn.ll (+12-19)
``diff
diff --git a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
index a79c01cbe577a..c851b1b6f5eb7 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
@@ -1389,6 +1389,14 @@ def : Pat<(xor (vt LASX256:$xj), (vt LASX256:$xk)),
foreach vt = [v32i8, v16i16, v8i32, v4i64] in
def : Pat<(vnot (or (vt LASX256:$xj), (vt LASX256:$xk))),
(XVNOR_V LASX256:$xj, LASX256:$xk)>;
+// XVANDN_V
+foreach vt = [v32i8, v16i16, v8i32, v4i64] in
+def : Pat<(and (vt (vnot LASX256:$xj)), (vt LASX256:$xk)),
+ (XVANDN_V LASX256:$xj, LASX256:$xk)>;
+// XVORN_V
+foreach vt = [v32i8, v16i16, v8i32, v4i64] in
+def : Pat<(or (vt LASX256:$xj), (vt (vnot LASX256:$xk))),
+ (XVORN_V LASX256:$xj, LASX256:$xk)>;
// XVANDI_B
def : Pat<(and (v32i8 LASX256:$xj), (v32i8 (SplatPat_uimm8 uimm8:$imm))),
diff --git a/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
b/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
index eb7120ffb41a6..fe7c47543424b 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
@@ -1583,6 +1583,14 @@ def : Pat<(xor (vt LSX128:$vj), (vt LSX128:$vk)),
foreach vt = [v16i8, v8i16, v4i32, v2i64] in
def : Pat<(vnot (or (vt LSX128:$vj), (vt LSX128:$vk))),
(VNOR_V LSX128:$vj, LSX128:$vk)>;
+// VANDN_V
+foreach vt = [v16i8, v8i16, v4i32, v2i64] in
+def : Pat<(and (vt (vnot LSX128:$vj)), (vt LSX128:$vk)),
+ (VANDN_V LSX128:$vj, LSX128:$vk)>;
+// VORN_V
+foreach vt = [v16i8, v8i16, v4i32, v2i64] in
+def : Pat<(or (vt LSX128:$vj), (vt (vnot LSX128:$vk))),
+ (VORN_V LSX128:$vj, LSX128:$vk)>;
// VANDI_B
def : Pat<(and (v16i8 LSX128:$vj), (v16i8 (SplatPat_uimm8 uimm8:$imm))),
diff --git a/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
b/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
index 9f148e5a447a5..786233018ad7d 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
@@ -47,9 +47,7 @@ define <4 x i64> @lasx_xvbitclr_d(<4 x i64> %va, <4 x i64>
%vb) nounwind {
; LA32-NEXT:xvand.v $xr1, $xr1, $xr2
; LA32-NEXT:xvrepli.d $xr2, 1
; LA32-NEXT:xvsll.d $xr1, $xr2, $xr1
-; LA32-NEXT:xvrepli.b $xr2, -1
-; LA32-NEXT:xvxor.v $xr1, $xr1, $xr2
-; LA32-NEXT:xvand.v $xr0, $xr0, $xr1
+; LA32-NEXT:xvandn.v $xr0, $xr1, $xr0
; LA32-NEXT:ret
;
; LA64-LABEL: lasx_xvbitclr_d:
diff --git a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
index ea3b6144805ae..a61d016b8e21e 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
@@ -7,8 +7,7 @@ define void @andn_v32i8(ptr %res, ptr %a0, ptr %a1) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:xvld $xr0, $a1, 0
; CHECK-NEXT:xvld $xr1, $a2, 0
-; CHECK-NEXT:xvxori.b $xr0, $xr0, 255
-; CHECK-NEXT:xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT:xvandn.v $xr0, $xr0, $xr1
; CHECK-NEXT:xvst $xr0, $a0, 0
; CHECK-NEXT:ret
entry:
@@ -25,9 +24,7 @@ define void @andn_v16i16(ptr %res, ptr %a0, ptr %a1) nounwind
{
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:xvld $xr0, $a1, 0
; CHECK-NEXT:xvld $xr1, $a2, 0
-; CHECK-NEXT:xvrepli.b $xr2, -1
-; CHECK-NEXT:xvxor.v $xr0, $xr0, $xr2
-; CHECK-NEXT:xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT:xvandn.v $xr0, $xr0, $xr1
; CHECK-NEXT:xvst $xr0, $a0, 0
; CHECK-NEXT:ret
entry:
@@ -44,9 +41,7 @@ define void @andn_v8i32(ptr %res, ptr %a0, ptr %a1) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:xvld $xr0, $a1, 0
; CHECK-NEXT:xvld $xr1, $a2, 0
-; CHECK-NEXT:xvrepli.b $xr2, -1
-; CHECK-NEXT:xvxor.v $xr0, $xr0, $xr2
-; CHECK-NEXT:xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT:xvandn.v $xr0, $xr0, $xr1
; CHECK-NEXT:xvst $xr0, $a0, 0
; CHECK-NEXT:ret
entry:
@@ -63,9 +58,7 @@ define void @andn_v4i64(ptr %res, ptr %a0, ptr %a1) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:
[llvm-branch-commits] [llvm] [LoongArch] Add generation support for `[x]{vandn/vorn}.v` (PR #158526)
https://github.com/zhaoqi5 created
https://github.com/llvm/llvm-project/pull/158526
None
>From 972bb685b48e7615c127cb3f8c05151d10f356f3 Mon Sep 17 00:00:00 2001
From: Qi Zhao
Date: Mon, 15 Sep 2025 09:58:13 +0800
Subject: [PATCH 1/2] [LoongArch] Add generation support for
`[x]{vandn/vorn}.v`
---
llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td | 8
llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td | 8
2 files changed, 16 insertions(+)
diff --git a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
index a79c01cbe577a..c851b1b6f5eb7 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
@@ -1389,6 +1389,14 @@ def : Pat<(xor (vt LASX256:$xj), (vt LASX256:$xk)),
foreach vt = [v32i8, v16i16, v8i32, v4i64] in
def : Pat<(vnot (or (vt LASX256:$xj), (vt LASX256:$xk))),
(XVNOR_V LASX256:$xj, LASX256:$xk)>;
+// XVANDN_V
+foreach vt = [v32i8, v16i16, v8i32, v4i64] in
+def : Pat<(and (vt (vnot LASX256:$xj)), (vt LASX256:$xk)),
+ (XVANDN_V LASX256:$xj, LASX256:$xk)>;
+// XVORN_V
+foreach vt = [v32i8, v16i16, v8i32, v4i64] in
+def : Pat<(or (vt LASX256:$xj), (vt (vnot LASX256:$xk))),
+ (XVORN_V LASX256:$xj, LASX256:$xk)>;
// XVANDI_B
def : Pat<(and (v32i8 LASX256:$xj), (v32i8 (SplatPat_uimm8 uimm8:$imm))),
diff --git a/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
b/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
index eb7120ffb41a6..fe7c47543424b 100644
--- a/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
+++ b/llvm/lib/Target/LoongArch/LoongArchLSXInstrInfo.td
@@ -1583,6 +1583,14 @@ def : Pat<(xor (vt LSX128:$vj), (vt LSX128:$vk)),
foreach vt = [v16i8, v8i16, v4i32, v2i64] in
def : Pat<(vnot (or (vt LSX128:$vj), (vt LSX128:$vk))),
(VNOR_V LSX128:$vj, LSX128:$vk)>;
+// VANDN_V
+foreach vt = [v16i8, v8i16, v4i32, v2i64] in
+def : Pat<(and (vt (vnot LSX128:$vj)), (vt LSX128:$vk)),
+ (VANDN_V LSX128:$vj, LSX128:$vk)>;
+// VORN_V
+foreach vt = [v16i8, v8i16, v4i32, v2i64] in
+def : Pat<(or (vt LSX128:$vj), (vt (vnot LSX128:$vk))),
+ (VORN_V LSX128:$vj, LSX128:$vk)>;
// VANDI_B
def : Pat<(and (v16i8 LSX128:$vj), (v16i8 (SplatPat_uimm8 uimm8:$imm))),
>From 73eccdb9efb74569a9358aecd868616204270875 Mon Sep 17 00:00:00 2001
From: Qi Zhao
Date: Mon, 15 Sep 2025 09:59:46 +0800
Subject: [PATCH 2/2] update tests
---
.../LoongArch/lasx/intrinsic-bitclr.ll| 4 +--
.../LoongArch/lasx/ir-instruction/andn.ll | 15 +++--
.../LoongArch/lasx/ir-instruction/orn.ll | 31 +++
.../CodeGen/LoongArch/lsx/intrinsic-bitclr.ll | 4 +--
.../LoongArch/lsx/ir-instruction/andn.ll | 15 +++--
.../LoongArch/lsx/ir-instruction/orn.ll | 31 +++
6 files changed, 34 insertions(+), 66 deletions(-)
diff --git a/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
b/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
index 9f148e5a447a5..786233018ad7d 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/intrinsic-bitclr.ll
@@ -47,9 +47,7 @@ define <4 x i64> @lasx_xvbitclr_d(<4 x i64> %va, <4 x i64>
%vb) nounwind {
; LA32-NEXT:xvand.v $xr1, $xr1, $xr2
; LA32-NEXT:xvrepli.d $xr2, 1
; LA32-NEXT:xvsll.d $xr1, $xr2, $xr1
-; LA32-NEXT:xvrepli.b $xr2, -1
-; LA32-NEXT:xvxor.v $xr1, $xr1, $xr2
-; LA32-NEXT:xvand.v $xr0, $xr0, $xr1
+; LA32-NEXT:xvandn.v $xr0, $xr1, $xr0
; LA32-NEXT:ret
;
; LA64-LABEL: lasx_xvbitclr_d:
diff --git a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
index ea3b6144805ae..a61d016b8e21e 100644
--- a/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
+++ b/llvm/test/CodeGen/LoongArch/lasx/ir-instruction/andn.ll
@@ -7,8 +7,7 @@ define void @andn_v32i8(ptr %res, ptr %a0, ptr %a1) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:xvld $xr0, $a1, 0
; CHECK-NEXT:xvld $xr1, $a2, 0
-; CHECK-NEXT:xvxori.b $xr0, $xr0, 255
-; CHECK-NEXT:xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT:xvandn.v $xr0, $xr0, $xr1
; CHECK-NEXT:xvst $xr0, $a0, 0
; CHECK-NEXT:ret
entry:
@@ -25,9 +24,7 @@ define void @andn_v16i16(ptr %res, ptr %a0, ptr %a1) nounwind
{
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:xvld $xr0, $a1, 0
; CHECK-NEXT:xvld $xr1, $a2, 0
-; CHECK-NEXT:xvrepli.b $xr2, -1
-; CHECK-NEXT:xvxor.v $xr0, $xr0, $xr2
-; CHECK-NEXT:xvand.v $xr0, $xr0, $xr1
+; CHECK-NEXT:xvandn.v $xr0, $xr0, $xr1
; CHECK-NEXT:xvst $xr0, $a0, 0
; CHECK-NEXT:ret
entry:
@@ -44,9 +41,7 @@ define void @andn_v8i32(ptr %res, ptr %a0, ptr %a1) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT:xvld $xr0, $a1, 0
; CHECK-NEXT:xvld $xr1, $a2, 0
-; CHECK-NEXT:xvrepli.b $xr2, -1
-; CHECK-NEXT:xvxor.v $xr0, $xr0, $xr2
-; CHECK-NEXT:
