[llvm] a9a0120 - [AArch64] Add additional tests for sinking free shuffles for FMAs.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 02:35:54 PDT 2022


Author: Florian Hahn
Date: 2022-05-26T10:35:38+01:00
New Revision: a9a012086a917dff367bb63de2d63782b23111fc

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

LOG: [AArch64] Add additional tests for sinking free shuffles for FMAs.

Added: 
    

Modified: 
    llvm/test/Transforms/CodeGenPrepare/AArch64/sink-free-instructions.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/CodeGenPrepare/AArch64/sink-free-instructions.ll b/llvm/test/Transforms/CodeGenPrepare/AArch64/sink-free-instructions.ll
index 244d2c35bbacb..5d7a26f657845 100644
--- a/llvm/test/Transforms/CodeGenPrepare/AArch64/sink-free-instructions.ll
+++ b/llvm/test/Transforms/CodeGenPrepare/AArch64/sink-free-instructions.ll
@@ -585,6 +585,43 @@ if.else:
   ret <4 x float> %r.3
 }
 
+define <4 x float> @sink_shufflevector_first_arg_fma_v4f3(i1 %c, <8 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: @sink_shufflevector_first_arg_fma_v4f3(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[S0:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> poison, <4 x i32> zeroinitializer
+; CHECK-NEXT:    [[S1:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
+; CHECK-NEXT:    [[S2:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
+; CHECK-NEXT:    [[S3:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
+; CHECK-NEXT:    br i1 [[C:%.*]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
+; CHECK:       if.then:
+; CHECK-NEXT:    [[R_0:%.*]] = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> [[S0]], <4 x float> [[B:%.*]], <4 x float> [[B]])
+; CHECK-NEXT:    [[R_1:%.*]] = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> [[S1]], <4 x float> [[R_0]], <4 x float> [[B]])
+; CHECK-NEXT:    ret <4 x float> [[R_1]]
+; CHECK:       if.else:
+; CHECK-NEXT:    [[R_2:%.*]] = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> [[S2]], <4 x float> [[B]], <4 x float> [[B]])
+; CHECK-NEXT:    [[R_3:%.*]] = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> [[S3]], <4 x float> [[R_2]], <4 x float> [[B]])
+; CHECK-NEXT:    ret <4 x float> [[R_3]]
+;
+entry:
+  %s0 = shufflevector <8 x float> %a, <8 x float> poison, <4 x i32> zeroinitializer
+  %s1 = shufflevector <8 x float> %a, <8 x float> poison, <4 x i32> <i32 1, i32 1, i32 1, i32 1>
+  %s2 = shufflevector <8 x float> %a, <8 x float> poison, <4 x i32> <i32 2, i32 2, i32 2, i32 2>
+  %s3 = shufflevector <8 x float> %a, <8 x float> poison, <4 x i32> <i32 3, i32 3, i32 3, i32 3>
+  br i1 %c, label %if.then, label %if.else
+
+if.then:
+  %r.0 = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> %s0, <4 x float> %b, <4 x float> %b)
+  %r.1 = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> %s1, <4 x float> %r.0, <4 x float> %b)
+  ret <4 x float> %r.1
+
+if.else:
+  %r.2 = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> %s2, <4 x float> %b, <4 x float> %b)
+  %r.3 = tail call fast <4 x float> @llvm.fma.v4f32(<4 x float> %s3, <4 x float> %r.2, <4 x float> %b)
+  ret <4 x float> %r.3
+}
+
+
+
 declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>)
 
 define <2 x double> @sink_shufflevector_fma_v2f64(i1 %c, <2 x double> %a, <2 x double> %b) {
@@ -639,8 +676,8 @@ if.else:
 
 declare <5 x float> @llvm.fma.v5f32(<5 x float>, <5 x float>, <5 x float>)
 
-define <5 x float> @do_not_sink_shufflevector_fma_v5f32(i1 %c, <8 x float> %a, <5 x float> %b) {
-; CHECK-LABEL: @do_not_sink_shufflevector_fma_v5f32(
+define <5 x float> @sink_shufflevector_fma_v5f32(i1 %c, <8 x float> %a, <5 x float> %b) {
+; CHECK-LABEL: @sink_shufflevector_fma_v5f32(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[S0:%.*]] = shufflevector <8 x float> [[A:%.*]], <8 x float> poison, <5 x i32> zeroinitializer
 ; CHECK-NEXT:    [[S1:%.*]] = shufflevector <8 x float> [[A]], <8 x float> poison, <5 x i32> <i32 1, i32 1, i32 1, i32 1, i32 4>


        


More information about the llvm-commits mailing list