[InstCombine] Simplify test cases by removing loads/stores that aren't required for what is being tested.

The loads and stores were getting the data and storing the results. There's no reason we can't just use function arguments and return.

llvm-svn: 326515
This commit is contained in:
Craig Topper 2018-03-02 00:27:44 +00:00
parent 4c693a894f
commit 113446ca37
1 changed files with 40 additions and 72 deletions

View File

@ -1,120 +1,88 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine -S | FileCheck %s
@X = external global float
@Y = external global float
@Z = external global <2 x float>
define void @test() nounwind {
define float @test(float %x) nounwind {
; CHECK-LABEL: @test(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = load float, float* @X, align 4
; CHECK-NEXT: [[TMP34:%.*]] = fadd float [[TMP]], 0.000000e+00
; CHECK-NEXT: store float [[TMP34]], float* @X, align 4
; CHECK-NEXT: ret void
; CHECK-NEXT: [[TMP34:%.*]] = fadd float [[X:%.*]], 0.000000e+00
; CHECK-NEXT: ret float [[TMP34]]
;
entry:
%tmp = load float, float* @X, align 4 ; <float> [#uses=1]
%tmp1 = fpext float %tmp to double ; <double> [#uses=1]
%tmp3 = fadd double %tmp1, 0.000000e+00 ; <double> [#uses=1]
%tmp34 = fptrunc double %tmp3 to float ; <float> [#uses=1]
store float %tmp34, float* @X, align 4
ret void
%tmp1 = fpext float %x to double
%tmp3 = fadd double %tmp1, 0.000000e+00
%tmp34 = fptrunc double %tmp3 to float
ret float %tmp34
}
define void @test2() nounwind {
define float @test2(float %x, float %y) nounwind {
; CHECK-LABEL: @test2(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = load float, float* @X, align 4
; CHECK-NEXT: [[TMP2:%.*]] = load float, float* @Y, align 4
; CHECK-NEXT: [[TMP56:%.*]] = fmul float [[TMP]], [[TMP2]]
; CHECK-NEXT: store float [[TMP56]], float* @X, align 4
; CHECK-NEXT: ret void
; CHECK-NEXT: [[TMP56:%.*]] = fmul float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret float [[TMP56]]
;
entry:
%tmp = load float, float* @X, align 4 ; <float> [#uses=1]
%tmp1 = fpext float %tmp to double ; <double> [#uses=1]
%tmp2 = load float, float* @Y, align 4 ; <float> [#uses=1]
%tmp23 = fpext float %tmp2 to double ; <double> [#uses=1]
%tmp5 = fmul double %tmp1, %tmp23 ; <double> [#uses=1]
%tmp56 = fptrunc double %tmp5 to float ; <float> [#uses=1]
store float %tmp56, float* @X, align 4
ret void
%tmp1 = fpext float %x to double
%tmp23 = fpext float %y to double
%tmp5 = fmul double %tmp1, %tmp23
%tmp56 = fptrunc double %tmp5 to float
ret float %tmp56
}
define void @test3() nounwind {
define float @test3(float %x, float %y) nounwind {
; CHECK-LABEL: @test3(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = load float, float* @X, align 4
; CHECK-NEXT: [[TMP2:%.*]] = load float, float* @Y, align 4
; CHECK-NEXT: [[TMP56:%.*]] = fdiv float [[TMP]], [[TMP2]]
; CHECK-NEXT: store float [[TMP56]], float* @X, align 4
; CHECK-NEXT: ret void
; CHECK-NEXT: [[TMP56:%.*]] = fdiv float [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret float [[TMP56]]
;
entry:
%tmp = load float, float* @X, align 4 ; <float> [#uses=1]
%tmp1 = fpext float %tmp to double ; <double> [#uses=1]
%tmp2 = load float, float* @Y, align 4 ; <float> [#uses=1]
%tmp23 = fpext float %tmp2 to double ; <double> [#uses=1]
%tmp5 = fdiv double %tmp1, %tmp23 ; <double> [#uses=1]
%tmp56 = fptrunc double %tmp5 to float ; <float> [#uses=1]
store float %tmp56, float* @X, align 4
ret void
%tmp1 = fpext float %x to double
%tmp23 = fpext float %y to double
%tmp5 = fdiv double %tmp1, %tmp23
%tmp56 = fptrunc double %tmp5 to float
ret float %tmp56
}
define void @test4() nounwind {
define float @test4(float %x) nounwind {
; CHECK-LABEL: @test4(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = load float, float* @X, align 4
; CHECK-NEXT: [[TMP34:%.*]] = fsub float -0.000000e+00, [[TMP]]
; CHECK-NEXT: store float [[TMP34]], float* @X, align 4
; CHECK-NEXT: ret void
; CHECK-NEXT: [[TMP34:%.*]] = fsub float -0.000000e+00, [[X:%.*]]
; CHECK-NEXT: ret float [[TMP34]]
;
entry:
%tmp = load float, float* @X, align 4 ; <float> [#uses=1]
%tmp1 = fpext float %tmp to double ; <double> [#uses=1]
%tmp2 = fsub double -0.000000e+00, %tmp1 ; <double> [#uses=1]
%tmp34 = fptrunc double %tmp2 to float ; <float> [#uses=1]
store float %tmp34, float* @X, align 4
ret void
%tmp1 = fpext float %x to double
%tmp2 = fsub double -0.000000e+00, %tmp1
%tmp34 = fptrunc double %tmp2 to float
ret float %tmp34
}
; Test with vector splat constant
define void @test5() nounwind {
define <2 x float> @test5(<2 x float> %x) nounwind {
; CHECK-LABEL: @test5(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = load <2 x float>, <2 x float>* @Z, align 8
; CHECK-NEXT: [[TMP1:%.*]] = fpext <2 x float> [[TMP]] to <2 x double>
; CHECK-NEXT: [[TMP1:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT: [[TMP3:%.*]] = fadd <2 x double> [[TMP1]], zeroinitializer
; CHECK-NEXT: [[TMP34:%.*]] = fptrunc <2 x double> [[TMP3]] to <2 x float>
; CHECK-NEXT: store <2 x float> [[TMP34]], <2 x float>* @Z, align 8
; CHECK-NEXT: ret void
; CHECK-NEXT: ret <2 x float> [[TMP34]]
;
entry:
%tmp = load <2 x float>, <2 x float>* @Z, align 4
%tmp1 = fpext <2 x float> %tmp to <2 x double>
%tmp1 = fpext <2 x float> %x to <2 x double>
%tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double 0.000000e+00>
%tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
store <2 x float> %tmp34, <2 x float>* @Z, align 4
ret void
ret <2 x float> %tmp34
}
; Test with a non-splat constant
define void @test6() nounwind {
define <2 x float> @test6(<2 x float> %x) nounwind {
; CHECK-LABEL: @test6(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP:%.*]] = load <2 x float>, <2 x float>* @Z, align 8
; CHECK-NEXT: [[TMP1:%.*]] = fpext <2 x float> [[TMP]] to <2 x double>
; CHECK-NEXT: [[TMP1:%.*]] = fpext <2 x float> [[X:%.*]] to <2 x double>
; CHECK-NEXT: [[TMP3:%.*]] = fadd <2 x double> [[TMP1]], <double 0.000000e+00, double -0.000000e+00>
; CHECK-NEXT: [[TMP34:%.*]] = fptrunc <2 x double> [[TMP3]] to <2 x float>
; CHECK-NEXT: store <2 x float> [[TMP34]], <2 x float>* @Z, align 8
; CHECK-NEXT: ret void
; CHECK-NEXT: ret <2 x float> [[TMP34]]
;
entry:
%tmp = load <2 x float>, <2 x float>* @Z, align 4
%tmp1 = fpext <2 x float> %tmp to <2 x double>
%tmp1 = fpext <2 x float> %x to <2 x double>
%tmp3 = fadd <2 x double> %tmp1, <double 0.000000e+00, double -0.000000e+00>
%tmp34 = fptrunc <2 x double> %tmp3 to <2 x float>
store <2 x float> %tmp34, <2 x float>* @Z, align 4
ret void
ret <2 x float> %tmp34
}