1 ; NOTE: Assertions have been autogenerated by update_test_checks.py 2 ; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4 ; fsub -0.0, (fsub -0.0, X) ==> X 5 define float @fsub_-0_-0_x(float %a) { 6 ; CHECK-LABEL: @fsub_-0_-0_x( 7 ; CHECK: ret float %a 8 ; 9 %t1 = fsub float -0.0, %a 10 %ret = fsub float -0.0, %t1 11 ret float %ret 12 } 13 14 ; fsub 0.0, (fsub -0.0, X) != X 15 define float @fsub_0_-0_x(float %a) { 16 ; CHECK-LABEL: @fsub_0_-0_x( 17 ; CHECK: [[T1:%.*]] = fsub float 0.000000e+00, %a 18 ; CHECK-NEXT: [[RET:%.*]] = fsub float -0.000000e+00, [[T1]] 19 ; CHECK-NEXT: ret float [[RET]] 20 ; 21 %t1 = fsub float 0.0, %a 22 %ret = fsub float -0.0, %t1 23 ret float %ret 24 } 25 26 ; fsub -0.0, (fsub 0.0, X) != X 27 define float @fsub_-0_0_x(float %a) { 28 ; CHECK-LABEL: @fsub_-0_0_x( 29 ; CHECK: [[T1:%.*]] = fsub float -0.000000e+00, %a 30 ; CHECK-NEXT: [[RET:%.*]] = fsub float 0.000000e+00, [[T1]] 31 ; CHECK-NEXT: ret float [[RET]] 32 ; 33 %t1 = fsub float -0.0, %a 34 %ret = fsub float 0.0, %t1 35 ret float %ret 36 } 37 38 ; fsub X, 0 ==> X 39 define float @fsub_x_0(float %a) { 40 ; CHECK-LABEL: @fsub_x_0( 41 ; CHECK: ret float %a 42 ; 43 %ret = fsub float %a, 0.0 44 ret float %ret 45 } 46 47 ; fadd X, -0 ==> X 48 define float @fadd_x_n0(float %a) { 49 ; CHECK-LABEL: @fadd_x_n0( 50 ; CHECK: ret float %a 51 ; 52 %ret = fadd float %a, -0.0 53 ret float %ret 54 } 55 56 ; fmul X, 1.0 ==> X 57 define double @fmul_X_1(double %a) { 58 ; CHECK-LABEL: @fmul_X_1( 59 ; CHECK: ret double %a 60 ; 61 %b = fmul double 1.000000e+00, %a 62 ret double %b 63 } 64 65 ; We can't optimize away the fadd in this test because the input 66 ; value to the function and subsequently to the fadd may be -0.0. 67 ; In that one special case, the result of the fadd should be +0.0 68 ; rather than the first parameter of the fadd. 69 70 ; Fragile test warning: We need 6 sqrt calls to trigger the bug 71 ; because the internal logic has a magic recursion limit of 6. 72 ; This is presented without any explanation or ability to customize. 73 74 declare float @sqrtf(float) 75 76 define float @PR22688(float %x) { 77 ; CHECK-LABEL: @PR22688( 78 ; CHECK: [[TMP7:%.*]] = fadd float {{%.*}}, 0.000000e+00 79 ; CHECK-NEXT: ret float [[TMP7]] 80 ; 81 %1 = call float @sqrtf(float %x) 82 %2 = call float @sqrtf(float %1) 83 %3 = call float @sqrtf(float %2) 84 %4 = call float @sqrtf(float %3) 85 %5 = call float @sqrtf(float %4) 86 %6 = call float @sqrtf(float %5) 87 %7 = fadd float %6, 0.0 88 ret float %7 89 } 90 91