@@ -885,29 +885,29 @@ bb0(%0 : $Builtin.FPIEEE32):
885
885
// CHECK: } // end sil function 'dont_fold_comparison_with_inf'
886
886
}
887
887
888
- sil @dont_fold_comparison_with_inf2 : $@convention(thin) () -> Builtin.Int1 {
888
+ sil @fold_comparison_with_inf : $@convention(thin) () -> Builtin.Int1 {
889
889
bb0:
890
890
%2 = float_literal $Builtin.FPIEEE32, 0x7F800000 // +Inf // user: %3
891
891
%5 = integer_literal $Builtin.Int32, 2139095040
892
892
%6 = builtin "bitcast_Int32_FPIEEE32"(%5 : $Builtin.Int32) : $Builtin.FPIEEE32
893
893
%9 = builtin "fcmp_olt_FPIEEE32"(%2 : $Builtin.FPIEEE32, %6 : $Builtin.FPIEEE32) : $Builtin.Int1
894
894
return %9 : $Builtin.Int1
895
895
896
- // CHECK-LABEL: sil @dont_fold_comparison_with_inf2 :
897
- // CHECK: [[R:%.*]] = builtin "fcmp_olt_FPIEEE32"
896
+ // CHECK-LABEL: sil @fold_comparison_with_inf :
897
+ // CHECK: [[R:%.*]] = integer_literal $Builtin.Int1, 0
898
898
// CHECK: return [[R]]
899
- // CHECK: } // end sil function 'dont_fold_comparison_with_inf2 '
899
+ // CHECK: } // end sil function 'fold_comparison_with_inf '
900
900
}
901
901
902
902
// fold float comparison operations with Infinity/NaN when the other argument is not constant
903
903
sil @fold_float_comparison_with_non_constant_arg : $@convention(thin) (Float) -> () {
904
904
bb0(%0: $Float):
905
905
%1 = struct_extract %0 : $Float, #Float._value
906
906
907
- %2 = integer_literal $Builtin.Int32, 2143289344 // user: %3
907
+ %2 = integer_literal $Builtin.Int32, 2143289344
908
908
%3 = builtin "bitcast_Int32_FPIEEE32"(%2 : $Builtin.Int32) : $Builtin.FPIEEE32 // NaN
909
909
910
- %4 = integer_literal $Builtin.Int32, 2139095040 // user: %4
910
+ %4 = integer_literal $Builtin.Int32, 2139095040
911
911
%5 = builtin "bitcast_Int32_FPIEEE32"(%4 : $Builtin.Int32) : $Builtin.FPIEEE32 // Inf
912
912
913
913
%6 = builtin "fcmp_oge_FPIEEE32"(%3 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
@@ -917,20 +917,19 @@ bb0(%0: $Float):
917
917
return %8 : $()
918
918
919
919
// CHECK-LABEL: sil @fold_float_comparison_with_non_constant_arg
920
- // CHECK: bb0(%0 : $Float):
921
- // CHECK-NEXT: %1 = struct_extract %0 : $Float, #Float._value // user: %5
922
- // CHECK-NEXT: %2 = integer_literal $Builtin.Int32, 2139095040 // user: %3
923
- // CHECK-NEXT: %3 = builtin "bitcast_Int32_FPIEEE32"(%2 : $Builtin.Int32) : $Builtin.FPIEEE32 // user: %5
920
+ // CHECK: bb0(%0 : $Float):
921
+ // CHECK-NEXT: %1 = struct_extract %0 : $Float, #Float._value
922
+ // CHECK-NEXT: %2 = float_literal $Builtin.FPIEEE32, 0x7F800000 // +Inf
924
923
925
924
// Comparison with NaN is always folded
926
- // CHECK-NEXT: %4 = integer_literal $Builtin.Int1, 0
925
+ // CHECK-NEXT: %3 = integer_literal $Builtin.Int1, 0
927
926
928
927
// Comparison with Inf is not folded unless the other argument can be proven to be constant
929
- // CHECK-NEXT: %5 = builtin "fcmp_oge_FPIEEE32"(%3 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
928
+ // CHECK-NEXT: %4 = builtin "fcmp_oge_FPIEEE32"(%2 : $Builtin.FPIEEE32, %1 : $Builtin.FPIEEE32) : $Builtin.Int1
930
929
931
- // CHECK-NEXT: %6 = tuple () // user: %7
932
- // CHECK-NEXT: return %6 : $() // id: %7
933
- // CHECK-NEXT: } // end sil function 'fold_float_comparison_with_non_constant_arg'
930
+ // CHECK-NEXT: %5 = tuple ()
931
+ // CHECK-NEXT: return %5
932
+ // CHECK-NEXT: } // end sil function 'fold_float_comparison_with_non_constant_arg'
934
933
}
935
934
936
935
sil @fold_inf_comparisons_with_itself : $@convention(thin) () -> () {
@@ -987,6 +986,55 @@ sil @fold_inf_comparisons_with_itself : $@convention(thin) () -> () {
987
986
// CHECK: } // end sil function 'fold_inf_comparisons_with_itself'
988
987
}
989
988
989
+
990
+ // CHECK-LABEL: sil @fold_cast_to_fp :
991
+ // CHECK: bb0:
992
+ // CHECK-NEXT: %0 = float_literal $Builtin.FPIEEE64, 0x3FF0000000000000 // 1
993
+ // CHECK-NEXT: return %0 : $Builtin.FPIEEE64
994
+ // CHECK: } // end sil function 'fold_cast_to_fp'
995
+ sil @fold_cast_to_fp : $@convention(thin) () -> Builtin.FPIEEE64 {
996
+ bb0:
997
+ %0 = integer_literal $Builtin.Int64, 1
998
+ %1 = builtin "sitofp_Int64_FPIEEE64"(%0) : $Builtin.FPIEEE64
999
+ return %1
1000
+ }
1001
+
1002
+ // CHECK-LABEL: sil @fold_bitcast_to_fp :
1003
+ // CHECK: bb0:
1004
+ // CHECK-NEXT: %0 = float_literal $Builtin.FPIEEE64, 0x3FF0000000000000
1005
+ // CHECK-NEXT: return %0
1006
+ // CHECK: } // end sil function 'fold_bitcast_to_fp'
1007
+ sil @fold_bitcast_to_fp : $@convention(thin) () -> Builtin.FPIEEE64 {
1008
+ bb0:
1009
+ %0 = integer_literal $Builtin.Int64, 4607182418800017408
1010
+ %1 = builtin "bitcast_Int64_FPIEEE64"(%0) : $Builtin.FPIEEE64
1011
+ return %1
1012
+ }
1013
+
1014
+ // CHECK-LABEL: sil @fold_bitcast_to_int :
1015
+ // CHECK: bb0:
1016
+ // CHECK-NEXT: %0 = integer_literal $Builtin.Int64, 4607182418800017408
1017
+ // CHECK-NEXT: return %0
1018
+ // CHECK: } // end sil function 'fold_bitcast_to_int'
1019
+ sil @fold_bitcast_to_int : $@convention(thin) () -> Builtin.Int64 {
1020
+ bb0:
1021
+ %0 = float_literal $Builtin.FPIEEE64, 0x3FF0000000000000
1022
+ %1 = builtin "bitcast_FPIEEE64_Int64"(%0) : $Builtin.Int64
1023
+ return %1
1024
+ }
1025
+
1026
+ // CHECK-LABEL: sil @fold_rint :
1027
+ // CHECK: bb0:
1028
+ // CHECK-NEXT: %0 = float_literal $Builtin.FPIEEE64, 0x40F0000000000000 // 65536
1029
+ // CHECK-NEXT: return %0 : $Builtin.FPIEEE64
1030
+ // CHECK: } // end sil function 'fold_rint'
1031
+ sil @fold_rint : $@convention(thin) () -> Builtin.FPIEEE64 {
1032
+ bb0:
1033
+ %0 = float_literal $Builtin.FPIEEE64, 0x40F0000000000000 // 65536
1034
+ %1 = builtin "int_rint_FPIEEE64"(%0) : $Builtin.FPIEEE64
1035
+ return %1
1036
+ }
1037
+
990
1038
// fold float comparison operations with opaque values, that may be constant
991
1039
// but are hidden behind a struct or a tuple.
992
1040
sil @fold_float_comparison_between_opaque_val : $@convention(thin) () -> () {
0 commit comments