[PowerPC]add testcase for adding store (load float*) pattern, nfc
authorChen Zheng <czhengsz@cn.ibm.com>
Sat, 18 Jul 2020 02:51:00 +0000 (22:51 -0400)
committerChen Zheng <czhengsz@cn.ibm.com>
Sat, 18 Jul 2020 02:57:08 +0000 (22:57 -0400)
llvm/test/Transforms/SimplifyCFG/PowerPC/prefer-load-i32.ll [new file with mode: 0644]

diff --git a/llvm/test/Transforms/SimplifyCFG/PowerPC/prefer-load-i32.ll b/llvm/test/Transforms/SimplifyCFG/PowerPC/prefer-load-i32.ll
new file mode 100644 (file)
index 0000000..943fcba
--- /dev/null
@@ -0,0 +1,33 @@
+; RUN: opt < %s -mtriple=powerpc64le-unknown-linux-gnu -simplifycfg -S | \
+; RUN: FileCheck %s
+
+define float @foo(float* %src, float* %dest, i32 signext %count, i32 signext %cond) {
+; CHECK-LABEL: @foo(
+; CHECK-LABEL: entry:
+; CHECK:  %0 = load float, float* %arrayidx, align 4
+entry:
+  %cmp = icmp sgt i32 %cond, 10
+  %idxprom = sext i32 %count to i64
+  %arrayidx = getelementptr inbounds float, float* %src, i64 %idxprom
+  br i1 %cmp, label %if.then, label %if.else
+
+; CHECK-LABEL: if.then:
+; CHECK-NOT:   load float
+if.then:                                          ; preds = %entry
+  %0 = load float, float* %arrayidx, align 4
+  %res = fmul float %0, 3.000000e+00
+  br label %if.end
+
+; CHECK-LABEL: if.else:
+; CHECK-NOT:   load float
+if.else:                                          ; preds = %entry
+  %1 = load float, float* %arrayidx, align 4
+  %idxprom3 = sext i32 %count to i64
+  %arrayidx4 = getelementptr inbounds float, float* %dest, i64 %idxprom3
+  store float %1, float* %arrayidx4, align 4
+  br label %if.end
+
+if.end:                                           ; preds = %if.else, %if.then
+  %res2.0 = phi float [ %res, %if.then ], [ 0.000000e+00, %if.else ]
+  ret float %res2.0
+}