[llvm] 00ffc70 - [SLP][NFC]Add a test with commutative instruction with non-commutative op, NFC

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 12:58:29 PST 2025


Author: Alexey Bataev
Date: 2025-11-25T12:58:20-08:00
New Revision: 00ffc70ba154b8670fc37d1398ce4473bca3a516

URL: https://github.com/llvm/llvm-project/commit/00ffc70ba154b8670fc37d1398ce4473bca3a516
DIFF: https://github.com/llvm/llvm-project/commit/00ffc70ba154b8670fc37d1398ce4473bca3a516.diff

LOG: [SLP][NFC]Add a test with commutative instruction with non-commutative op, NFC

Added: 
    llvm/test/Transforms/SLPVectorizer/X86/non-commutative-op-in-commutative-inst.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/SLPVectorizer/X86/non-commutative-op-in-commutative-inst.ll b/llvm/test/Transforms/SLPVectorizer/X86/non-commutative-op-in-commutative-inst.ll
new file mode 100644
index 0000000000000..8c684325f8c68
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/X86/non-commutative-op-in-commutative-inst.ll
@@ -0,0 +1,33 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -S --passes=slp-vectorizer -mtriple=x86_64-unknown-linux-gnu -slp-threshold=-5 < %s | FileCheck %s
+
+declare float @llvm.fmuladd.f32(float, float, float)
+
+define void @test(ptr %quat, float %call13) {
+; CHECK-LABEL: define void @test(
+; CHECK-SAME: ptr [[QUAT:%.*]], float [[CALL13:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[CALL121:%.*]] = load volatile float, ptr null, align 4
+; CHECK-NEXT:    [[TMP0:%.*]] = call float @llvm.fmuladd.f32(float [[CALL13]], float 0.000000e+00, float 0.000000e+00)
+; CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.fmuladd.f32(float [[CALL121]], float 0.000000e+00, float 0.000000e+00)
+; CHECK-NEXT:    [[TMP2:%.*]] = fadd float [[TMP1]], 0.000000e+00
+; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <2 x float> poison, float [[CALL13]], i32 0
+; CHECK-NEXT:    [[TMP4:%.*]] = shufflevector <2 x float> [[TMP3]], <2 x float> poison, <2 x i32> zeroinitializer
+; CHECK-NEXT:    [[TMP5:%.*]] = insertelement <2 x float> poison, float [[TMP2]], i32 0
+; CHECK-NEXT:    [[TMP6:%.*]] = insertelement <2 x float> [[TMP5]], float [[TMP0]], i32 1
+; CHECK-NEXT:    [[TMP7:%.*]] = call <2 x float> @llvm.fmuladd.v2f32(<2 x float> [[TMP4]], <2 x float> zeroinitializer, <2 x float> [[TMP6]])
+; CHECK-NEXT:    store <2 x float> [[TMP7]], ptr [[QUAT]], align 4
+; CHECK-NEXT:    ret void
+;
+entry:
+  %call121 = load volatile float, ptr null, align 4
+  %0 = call float @llvm.fmuladd.f32(float %call13, float 0.000000e+00, float 0.000000e+00)
+  %1 = call float @llvm.fmuladd.f32(float %call13, float 0.000000e+00, float %0)
+  %2 = call float @llvm.fmuladd.f32(float %call121, float 0.000000e+00, float 0.000000e+00)
+  %3 = fadd float %2, 0.000000e+00
+  %4 = call float @llvm.fmuladd.f32(float %call13, float 0.000000e+00, float %3)
+  %arrayidx43.i = getelementptr i8, ptr %quat, i64 4
+  store float %1, ptr %arrayidx43.i, align 4
+  store float %4, ptr %quat, align 4
+  ret void
+}


        


More information about the llvm-commits mailing list