[llvm] [SLP][NFC]Add extra test with alternate add/sub vectorization, NFC (PR #213693)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 3 07:58:45 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Alexey Bataev (alexey-bataev)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/213693.diff
1 Files Affected:
- (added) llvm/test/Transforms/SLPVectorizer/AArch64/alt-addsub-signflip.ll (+58)
``````````diff
diff --git a/llvm/test/Transforms/SLPVectorizer/AArch64/alt-addsub-signflip.ll b/llvm/test/Transforms/SLPVectorizer/AArch64/alt-addsub-signflip.ll
new file mode 100644
index 0000000000000..d99f0a3925fcf
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/AArch64/alt-addsub-signflip.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -passes=slp-vectorizer -S -mtriple=aarch64-unknown-linux-gnu | FileCheck %s
+
+; The sign-flip form of an add/sub alternate node negates the second
+; operand in the subtracted lanes, so the nsw/nuw flags of the original
+; scalar adds and subtracts do not carry over to the combined add.
+
+define <4 x i32> @addsub_nsw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: @addsub_nsw(
+; CHECK-NEXT: [[TMP1:%.*]] = add nsw <4 x i32> [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[TMP3:%.*]] = sub nsw <4 x i32> [[A]], [[B]]
+; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> [[TMP3]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
+; CHECK-NEXT: ret <4 x i32> [[TMP2]]
+;
+ %a0 = extractelement <4 x i32> %a, i32 0
+ %a1 = extractelement <4 x i32> %a, i32 1
+ %a2 = extractelement <4 x i32> %a, i32 2
+ %a3 = extractelement <4 x i32> %a, i32 3
+ %b0 = extractelement <4 x i32> %b, i32 0
+ %b1 = extractelement <4 x i32> %b, i32 1
+ %b2 = extractelement <4 x i32> %b, i32 2
+ %b3 = extractelement <4 x i32> %b, i32 3
+ %s0 = add nsw i32 %a0, %b0
+ %s1 = sub nsw i32 %a1, %b1
+ %s2 = add nsw i32 %a2, %b2
+ %s3 = sub nsw i32 %a3, %b3
+ %r0 = insertelement <4 x i32> poison, i32 %s0, i32 0
+ %r1 = insertelement <4 x i32> %r0, i32 %s1, i32 1
+ %r2 = insertelement <4 x i32> %r1, i32 %s2, i32 2
+ %r3 = insertelement <4 x i32> %r2, i32 %s3, i32 3
+ ret <4 x i32> %r3
+}
+
+define <4 x i32> @addsub_nuw(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: @addsub_nuw(
+; CHECK-NEXT: [[TMP1:%.*]] = add nuw <4 x i32> [[A:%.*]], [[B:%.*]]
+; CHECK-NEXT: [[TMP3:%.*]] = sub nuw <4 x i32> [[A]], [[B]]
+; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> [[TMP3]], <4 x i32> <i32 0, i32 5, i32 2, i32 7>
+; CHECK-NEXT: ret <4 x i32> [[TMP2]]
+;
+ %a0 = extractelement <4 x i32> %a, i32 0
+ %a1 = extractelement <4 x i32> %a, i32 1
+ %a2 = extractelement <4 x i32> %a, i32 2
+ %a3 = extractelement <4 x i32> %a, i32 3
+ %b0 = extractelement <4 x i32> %b, i32 0
+ %b1 = extractelement <4 x i32> %b, i32 1
+ %b2 = extractelement <4 x i32> %b, i32 2
+ %b3 = extractelement <4 x i32> %b, i32 3
+ %s0 = add nuw i32 %a0, %b0
+ %s1 = sub nuw i32 %a1, %b1
+ %s2 = add nuw i32 %a2, %b2
+ %s3 = sub nuw i32 %a3, %b3
+ %r0 = insertelement <4 x i32> poison, i32 %s0, i32 0
+ %r1 = insertelement <4 x i32> %r0, i32 %s1, i32 1
+ %r2 = insertelement <4 x i32> %r1, i32 %s2, i32 2
+ %r3 = insertelement <4 x i32> %r2, i32 %s3, i32 3
+ ret <4 x i32> %r3
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/213693
More information about the llvm-commits
mailing list