llvm.org GIT mirror llvm / 328a9cb
[InstSimplify] add fdiv x/1.0 test and update checks; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289098 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjay Patel 2 years ago
1 changed file(s) with 25 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
None ; NOTE: Assertions have been autogenerated by update_test_checks.py
0 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
11 ; RUN: opt < %s -instsimplify -S | FileCheck %s
22
33 ; fsub -0.0, (fsub -0.0, X) ==> X
44 define float @fsub_-0_-0_x(float %a) {
55 ; CHECK-LABEL: @fsub_-0_-0_x(
6 ; CHECK: ret float %a
6 ; CHECK-NEXT: ret float %a
77 ;
88 %t1 = fsub float -0.0, %a
99 %ret = fsub float -0.0, %t1
1313 ; fsub 0.0, (fsub -0.0, X) != X
1414 define float @fsub_0_-0_x(float %a) {
1515 ; CHECK-LABEL: @fsub_0_-0_x(
16 ; CHECK: [[T1:%.*]] = fsub float 0.000000e+00, %a
16 ; CHECK-NEXT: [[T1:%.*]] = fsub float 0.000000e+00, %a
1717 ; CHECK-NEXT: [[RET:%.*]] = fsub float -0.000000e+00, [[T1]]
1818 ; CHECK-NEXT: ret float [[RET]]
1919 ;
2525 ; fsub -0.0, (fsub 0.0, X) != X
2626 define float @fsub_-0_0_x(float %a) {
2727 ; CHECK-LABEL: @fsub_-0_0_x(
28 ; CHECK: [[T1:%.*]] = fsub float -0.000000e+00, %a
28 ; CHECK-NEXT: [[T1:%.*]] = fsub float -0.000000e+00, %a
2929 ; CHECK-NEXT: [[RET:%.*]] = fsub float 0.000000e+00, [[T1]]
3030 ; CHECK-NEXT: ret float [[RET]]
3131 ;
3737 ; fsub X, 0 ==> X
3838 define float @fsub_x_0(float %a) {
3939 ; CHECK-LABEL: @fsub_x_0(
40 ; CHECK: ret float %a
40 ; CHECK-NEXT: ret float %a
4141 ;
4242 %ret = fsub float %a, 0.0
4343 ret float %ret
4646 ; fadd X, -0 ==> X
4747 define float @fadd_x_n0(float %a) {
4848 ; CHECK-LABEL: @fadd_x_n0(
49 ; CHECK: ret float %a
49 ; CHECK-NEXT: ret float %a
5050 ;
5151 %ret = fadd float %a, -0.0
5252 ret float %ret
5555 ; fmul X, 1.0 ==> X
5656 define double @fmul_X_1(double %a) {
5757 ; CHECK-LABEL: @fmul_X_1(
58 ; CHECK: ret double %a
58 ; CHECK-NEXT: ret double %a
5959 ;
6060 %b = fmul double 1.000000e+00, %a
6161 ret double %b
62 }
63
64 ; FIXME:
65 ; fdiv X, 1.0 ==> X
66 define float @fdiv_x_1(float %a) {
67 ; CHECK-LABEL: @fdiv_x_1(
68 ; CHECK-NEXT: [[RET:%.*]] = fdiv float %a, 1.000000e+00
69 ; CHECK-NEXT: ret float [[RET]]
70 ;
71 %ret = fdiv float %a, 1.0
72 ret float %ret
6273 }
6374
6475 ; We can't optimize away the fadd in this test because the input
7485
7586 define float @PR22688(float %x) {
7687 ; CHECK-LABEL: @PR22688(
77 ; CHECK: [[TMP7:%.*]] = fadd float {{%.*}}, 0.000000e+00
88 ; CHECK-NEXT: [[TMP1:%.*]] = call float @sqrtf(float %x)
89 ; CHECK-NEXT: [[TMP2:%.*]] = call float @sqrtf(float [[TMP1]])
90 ; CHECK-NEXT: [[TMP3:%.*]] = call float @sqrtf(float [[TMP2]])
91 ; CHECK-NEXT: [[TMP4:%.*]] = call float @sqrtf(float [[TMP3]])
92 ; CHECK-NEXT: [[TMP5:%.*]] = call float @sqrtf(float [[TMP4]])
93 ; CHECK-NEXT: [[TMP6:%.*]] = call float @sqrtf(float [[TMP5]])
94 ; CHECK-NEXT: [[TMP7:%.*]] = fadd float [[TMP6]], 0.000000e+00
7895 ; CHECK-NEXT: ret float [[TMP7]]
7996 ;
8097 %1 = call float @sqrtf(float %x)