# Changeset View

Changeset View

# Standalone View

Standalone View

# llvm/trunk/test/Transforms/InstCombine/double-float-shrink-2.ll

1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | ||
---|---|---|---|---|---|

2 | ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s | 2 | ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-linux" | FileCheck %s | ||

3 | ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck --check-prefixes=CHECK,DONT-SIMPLIFY %s | 3 | ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-win32" | FileCheck %s | ||

4 | ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck --check-prefixes=CHECK,C89-SIMPLIFY %s | 4 | ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" | FileCheck %s | ||

5 | ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s | 5 | ; RUN: opt < %s -instcombine -S -mtriple "i386-pc-mingw32" | FileCheck %s | ||

6 | ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s | 6 | ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-mingw32" | FileCheck %s | ||

7 | ; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck --check-prefixes=CHECK,DO-SIMPLIFY %s | 7 | ; RUN: opt < %s -instcombine -S -mtriple "sparc-sun-solaris" | FileCheck %s | ||

8 | ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" -enable-debugify 2>&1 | FileCheck --check-prefix=DBG-VALID %s | 8 | ; RUN: opt < %s -instcombine -S -mtriple "x86_64-pc-win32" -enable-debugify 2>&1 | FileCheck --check-prefix=DBG-VALID %s | ||

9 | 9 | | |||

10 | declare double @floor(double) | 10 | declare double @floor(double) | ||

11 | declare double @ceil(double) | 11 | declare double @ceil(double) | ||

12 | declare double @round(double) | 12 | declare double @round(double) | ||

13 | declare double @nearbyint(double) | 13 | declare double @nearbyint(double) | ||

14 | declare double @trunc(double) | 14 | declare double @trunc(double) | ||

15 | declare double @fabs(double) | 15 | declare double @fabs(double) | ||

Show All 40 Lines | 54 | ; | |||

56 | ; --> ceilf | 56 | ; --> ceilf | ||

57 | %E = call double @ceil(double %D) | 57 | %E = call double @ceil(double %D) | ||

58 | %F = fptrunc double %E to float | 58 | %F = fptrunc double %E to float | ||

59 | ret float %F | 59 | ret float %F | ||

60 | } | 60 | } | ||

61 | 61 | | |||

62 | define float @test_shrink_libcall_round(float %C) { | 62 | define float @test_shrink_libcall_round(float %C) { | ||

63 | ; CHECK-LABEL: @test_shrink_libcall_round( | 63 | ; CHECK-LABEL: @test_shrink_libcall_round( | ||

64 | 64 | ; CHECK-NEXT: [[F:%.*]] = call float @llvm.round.f32(float [[C:%.*]]) | |||

65 | ; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.round.f32(float [[C:%.*]]) | 65 | ; CHECK-NEXT: ret float [[F]] | ||

66 | ; DO-SIMPLIFY-NEXT: ret float [[F]] | | |||

67 | ; | | |||

68 | ; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double | | |||

69 | ; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @round(double [[D]]) | | |||

70 | ; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float | | |||

71 | ; DONT-SIMPLIFY-NEXT: ret float [[F]] | | |||

72 | ; | | |||

73 | ; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double | | |||

74 | ; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @round(double [[D]]) | | |||

75 | ; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float | | |||

76 | ; C89-SIMPLIFY-NEXT: ret float [[F]] | | |||

77 | ; | 66 | ; | ||

78 | %D = fpext float %C to double | 67 | %D = fpext float %C to double | ||

79 | ; --> roundf | 68 | ; --> roundf | ||

80 | %E = call double @round(double %D) | 69 | %E = call double @round(double %D) | ||

81 | %F = fptrunc double %E to float | 70 | %F = fptrunc double %E to float | ||

82 | ret float %F | 71 | ret float %F | ||

83 | } | 72 | } | ||

84 | 73 | | |||

85 | define float @test_shrink_libcall_nearbyint(float %C) { | 74 | define float @test_shrink_libcall_nearbyint(float %C) { | ||

86 | ; CHECK-LABEL: @test_shrink_libcall_nearbyint( | 75 | ; CHECK-LABEL: @test_shrink_libcall_nearbyint( | ||

87 | 76 | ; CHECK-NEXT: [[F:%.*]] = call float @llvm.nearbyint.f32(float [[C:%.*]]) | |||

88 | ; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.nearbyint.f32(float [[C:%.*]]) | 77 | ; CHECK-NEXT: ret float [[F]] | ||

89 | ; DO-SIMPLIFY-NEXT: ret float [[F]] | | |||

90 | ; | | |||

91 | ; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double | | |||

92 | ; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @nearbyint(double [[D]]) | | |||

93 | ; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float | | |||

94 | ; DONT-SIMPLIFY-NEXT: ret float [[F]] | | |||

95 | ; | | |||

96 | ; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double | | |||

97 | ; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @nearbyint(double [[D]]) | | |||

98 | ; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float | | |||

99 | ; C89-SIMPLIFY-NEXT: ret float [[F]] | | |||

100 | ; | 78 | ; | ||

101 | %D = fpext float %C to double | 79 | %D = fpext float %C to double | ||

102 | ; --> nearbyintf | 80 | ; --> nearbyintf | ||

103 | %E = call double @nearbyint(double %D) | 81 | %E = call double @nearbyint(double %D) | ||

104 | %F = fptrunc double %E to float | 82 | %F = fptrunc double %E to float | ||

105 | ret float %F | 83 | ret float %F | ||

106 | } | 84 | } | ||

107 | 85 | | |||

108 | define float @test_shrink_libcall_trunc(float %C) { | 86 | define float @test_shrink_libcall_trunc(float %C) { | ||

109 | ; CHECK-LABEL: @test_shrink_libcall_trunc( | 87 | ; CHECK-LABEL: @test_shrink_libcall_trunc( | ||

110 | 88 | ; CHECK-NEXT: [[F:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]]) | |||

111 | ; DO-SIMPLIFY-NEXT: [[F:%.*]] = call float @llvm.trunc.f32(float [[C:%.*]]) | 89 | ; CHECK-NEXT: ret float [[F]] | ||

112 | ; DO-SIMPLIFY-NEXT: ret float [[F]] | | |||

113 | ; | | |||

114 | ; DONT-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double | | |||

115 | ; DONT-SIMPLIFY-NEXT: [[E:%.*]] = call double @trunc(double [[D]]) | | |||

116 | ; DONT-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float | | |||

117 | ; DONT-SIMPLIFY-NEXT: ret float [[F]] | | |||

118 | ; | | |||

119 | ; C89-SIMPLIFY-NEXT: [[D:%.*]] = fpext float [[C:%.*]] to double | | |||

120 | ; C89-SIMPLIFY-NEXT: [[E:%.*]] = call double @trunc(double [[D]]) | | |||

121 | ; C89-SIMPLIFY-NEXT: [[F:%.*]] = fptrunc double [[E]] to float | | |||

122 | ; C89-SIMPLIFY-NEXT: ret float [[F]] | | |||

123 | ; | 90 | ; | ||

124 | %D = fpext float %C to double | 91 | %D = fpext float %C to double | ||

125 | ; --> truncf | 92 | ; --> truncf | ||

126 | %E = call double @trunc(double %D) | 93 | %E = call double @trunc(double %D) | ||

127 | %F = fptrunc double %E to float | 94 | %F = fptrunc double %E to float | ||

128 | ret float %F | 95 | ret float %F | ||

129 | } | 96 | } | ||

130 | 97 | | |||

▲ Show 20 Lines • Show All 557 Lines • Show Last 20 Lines |