; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s @flt_nan = constant float 0x7FF8000000000000, align 4 @flt_pos_min_subnormal = constant float 0x36A0000000000000, align 4 @flt_pos_min_normal = constant float 0x3810000000000000, align 4 @flt_pos_max = constant float 0x47EFFFFFE0000000, align 4 @flt_pos_infinity = constant float 0x7FF0000000000000, align 4 @flt_neg_min_subnormal = constant float 0xB6A0000000000000, align 4 @flt_neg_min_normal = constant float 0xB810000000000000, align 4 @flt_neg_max = constant float 0xC7EFFFFFE0000000, align 4 @flt_neg_infinity = constant float 0xFFF0000000000000, align 4 @dbl_nan = constant double 0x7FF8000000000000, align 8 @dbl_pos_min_subnormal = constant double 4.940660e-324, align 8 @dbl_pos_min_normal = constant double 0x10000000000000, align 8 @dbl_pos_max = constant double 0x7FEFFFFFFFFFFFFF, align 8 @dbl_pos_infinity = constant double 0x7FF0000000000000, align 8 @dbl_neg_min_subnormal = constant double -4.940660e-324, align 8 @dbl_neg_min_normal = constant double 0x8010000000000000, align 8 @dbl_neg_max = constant double 0xFFEFFFFFFFFFFFFF, align 8 @dbl_neg_infinity = constant double 0xFFF0000000000000, align 8 define double @nexttoward_up_direction() { ; CHECK-LABEL: define double @nexttoward_up_direction() { ; CHECK-NEXT: ret double f0x3FF0000000000001 ; %arg = fpext double 2.0 to fp128 %next = call double @nexttoward(double 1.0, fp128 %arg) ret double %next } define float @nexttowardf_up_direction() { ; CHECK-LABEL: define float @nexttowardf_up_direction() { ; CHECK-NEXT: ret float f0x3F800001 ; %arg = fpext float 2.0 to fp128 %next = call float @nexttowardf(float 1.0, fp128 %arg) ret float %next } define double @nexttoward_down_direction() { ; CHECK-LABEL: define double @nexttoward_down_direction() { ; CHECK-NEXT: ret double f0x3FEFFFFFFFFFFFFF ; %arg = fpext double 0.0 to fp128 %next = call double @nexttoward(double 1.0, fp128 %arg) ret double %next } define float @nexttowardf_down_direction() { ; CHECK-LABEL: define float @nexttowardf_down_direction() { ; CHECK-NEXT: ret float f0x3F7FFFFF ; %arg = fpext float 0.0 to fp128 %next = call float @nexttowardf(float 1.0, fp128 %arg) ret float %next } define double @nexttoward_equal_args() { ; CHECK-LABEL: define double @nexttoward_equal_args() { ; CHECK-NEXT: ret double 1.000000e+00 ; %arg = fpext double 1.0 to fp128 %next = call double @nexttoward(double 1.0, fp128 %arg) ret double %next } define float @nexttowardf_equal_args() { ; CHECK-LABEL: define float @nexttowardf_equal_args() { ; CHECK-NEXT: ret float 1.000000e+00 ; %arg = fpext float 1.0 to fp128 %next = call float @nexttowardf(float 1.0, fp128 %arg) ret float %next } define double @nexttoward_pos_zero_neg_zero() { ; CHECK-LABEL: define double @nexttoward_pos_zero_neg_zero() { ; CHECK-NEXT: ret double -0.000000e+00 ; %neg_zero_ext = fpext double -0.0 to fp128 %next = call double @nexttoward(double 0.0, fp128 %neg_zero_ext) ret double %next } define float @nexttowardf_pos_zero_neg_zero() { ; CHECK-LABEL: define float @nexttowardf_pos_zero_neg_zero() { ; CHECK-NEXT: ret float -0.000000e+00 ; %neg_zero_ext = fpext float -0.0 to fp128 %next = call float @nexttowardf(float 0.0, fp128 %neg_zero_ext) ret float %next } define double @nexttoward_neg_zero_pos_zero() { ; CHECK-LABEL: define double @nexttoward_neg_zero_pos_zero() { ; CHECK-NEXT: ret double 0.000000e+00 ; %pos_zero_ext = fpext double 0.0 to fp128 %next = call double @nexttoward(double -0.0, fp128 %pos_zero_ext) ret double %next } define float @nexttowardf_neg_zero_pos_zero() { ; CHECK-LABEL: define float @nexttowardf_neg_zero_pos_zero() { ; CHECK-NEXT: ret float 0.000000e+00 ; %pos_zero_ext = fpext float 0.0 to fp128 %next = call float @nexttowardf(float -0.0, fp128 %pos_zero_ext) ret float %next } define double @nexttoward_nan_with_payload() { ; CHECK-LABEL: define double @nexttoward_nan_with_payload() { ; CHECK-NEXT: ret double +nan(0x1) ; %tmp1 = load i64, ptr @dbl_nan %tmp2 = or i64 %tmp1, 1 %nan_with_payload = bitcast i64 %tmp2 to double %dummy_arg = fpext double 1.0 to fp128 %next = call double @nexttoward(double %nan_with_payload, fp128 %dummy_arg) ret double %next } define float @nexttowardf_nan_with_payload() { ; CHECK-LABEL: define float @nexttowardf_nan_with_payload() { ; CHECK-NEXT: ret float +nan(0x1) ; %tmp1 = load i32, ptr @flt_nan %tmp2 = or i32 %tmp1, 1 %nan_with_payload = bitcast i32 %tmp2 to float %dummy_arg = fpext float 1.0 to fp128 %next = call float @nexttowardf(float %nan_with_payload, fp128 %dummy_arg) ret float %next } define double @nexttoward_pos_overflow() { ; CHECK-LABEL: define double @nexttoward_pos_overflow() { ; CHECK-NEXT: ret double +inf ; %pos_max = load double, ptr @dbl_pos_max %pos_inf = load double, ptr @dbl_pos_infinity %ext_pos_inf = fpext double %pos_inf to fp128 %next = call double @nexttoward(double %pos_max, fp128 %ext_pos_inf) ret double %next } define float @nexttowardf_pos_overflow () { ; CHECK-LABEL: define float @nexttowardf_pos_overflow() { ; CHECK-NEXT: ret float +inf ; %pos_max = load float, ptr @flt_pos_max %pos_inf = load float, ptr @flt_pos_infinity %ext_pos_inf = fpext float %pos_inf to fp128 %next = call float @nexttowardf(float %pos_max, fp128 %ext_pos_inf) ret float %next } define double @nexttoward_neg_overflow() { ; CHECK-LABEL: define double @nexttoward_neg_overflow() { ; CHECK-NEXT: ret double -inf ; %neg_max = load double, ptr @dbl_neg_max %neg_inf = load double, ptr @dbl_neg_infinity %ext_neg_inf = fpext double %neg_inf to fp128 %next = call double @nexttoward(double %neg_max, fp128 %ext_neg_inf) ret double %next } define float @nexttowardf_neg_overflow() { ; CHECK-LABEL: define float @nexttowardf_neg_overflow() { ; CHECK-NEXT: ret float -inf ; %neg_max = load float, ptr @flt_neg_max %neg_inf = load float, ptr @flt_neg_infinity %ext_neg_inf = fpext float %neg_inf to fp128 %next = call float @nexttowardf(float %neg_max, fp128 %ext_neg_inf) ret float %next } define double @nexttoward_zero_from_above() { ; CHECK-LABEL: define double @nexttoward_zero_from_above() { ; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 4.940660e-324, fp128 0.000000e+00) ; CHECK-NEXT: ret double [[NEXT]] ; %subnormal = load double, ptr @dbl_pos_min_subnormal %zero = fpext double 0.0 to fp128 %next = call double @nexttoward(double %subnormal, fp128 %zero) ret double %next } define float @nexttowardf_zero_from_above() { ; CHECK-LABEL: define float @nexttowardf_zero_from_above() { ; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 1.401300e-45, fp128 0.000000e+00) ; CHECK-NEXT: ret float [[NEXT]] ; %min_subnormal = load float, ptr @flt_pos_min_subnormal %zero = fpext float 0.0 to fp128 %next = call float @nexttowardf(float %min_subnormal, fp128 %zero) ret float %next } define double @nexttoward_zero_from_below() { ; CHECK-LABEL: define double @nexttoward_zero_from_below() { ; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double -4.940660e-324, fp128 0.000000e+00) ; CHECK-NEXT: ret double [[NEXT]] ; %subnormal = load double, ptr @dbl_neg_min_subnormal %zero = fpext double 0.0 to fp128 %next = call double @nexttoward(double %subnormal, fp128 %zero) ret double %next } define float @nexttowardf_zero_from_below() { ; CHECK-LABEL: define float @nexttowardf_zero_from_below() { ; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float -1.401300e-45, fp128 0.000000e+00) ; CHECK-NEXT: ret float [[NEXT]] ; %min_subnormal = load float, ptr @flt_neg_min_subnormal %zero = fpext float 0.0 to fp128 %next = call float @nexttowardf(float %min_subnormal, fp128 %zero) ret float %next } define double @nexttoward_subnormal() { ; CHECK-LABEL: define double @nexttoward_subnormal() { ; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 4.940660e-324, fp128 1.000000e+00) ; CHECK-NEXT: ret double [[NEXT]] ; %subnormal = load double, ptr @dbl_pos_min_subnormal %target = fpext double 1.0 to fp128 %next = call double @nexttoward(double %subnormal, fp128 %target) ret double %next } define float @nexttowardf_subnormal() { ; CHECK-LABEL: define float @nexttowardf_subnormal() { ; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 1.401300e-45, fp128 1.000000e+00) ; CHECK-NEXT: ret float [[NEXT]] ; %subnormal = load float, ptr @flt_pos_min_subnormal %target = fpext float 1.0 to fp128 %next = call float @nexttowardf(float %subnormal, fp128 %target) ret float %next } define double @nexttoward_poison() { ; CHECK-LABEL: define double @nexttoward_poison() { ; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double poison, fp128 1.000000e+00) ; CHECK-NEXT: ret double [[NEXT]] ; %dummy_arg = fpext double 1.0 to fp128 %next = call double @nexttoward(double poison, fp128 %dummy_arg) ret double %next } define float @nexttowardf_poison() { ; CHECK-LABEL: define float @nexttowardf_poison() { ; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float poison, fp128 1.000000e+00) ; CHECK-NEXT: ret float [[NEXT]] ; %dummy_arg = fpext double 1.0 to fp128 %next = call float @nexttowardf(float poison, fp128 %dummy_arg) ret float %next } define double @nexttoward_subnormal_readnone() { ; CHECK-LABEL: define double @nexttoward_subnormal_readnone() { ; CHECK-NEXT: [[NEXT:%.*]] = call double @nexttoward(double 4.940660e-324, fp128 1.000000e+00) #[[ATTR1:[0-9]+]] ; CHECK-NEXT: ret double [[NEXT]] ; %subnormal = load double, ptr @dbl_pos_min_subnormal %target = fpext double 1.0 to fp128 %next = call double @nexttoward(double %subnormal, fp128 %target) readnone ret double %next } define float @nexttowardf_subnormal_readnone() { ; CHECK-LABEL: define float @nexttowardf_subnormal_readnone() { ; CHECK-NEXT: [[NEXT:%.*]] = call float @nexttowardf(float 1.401300e-45, fp128 1.000000e+00) #[[ATTR1]] ; CHECK-NEXT: ret float [[NEXT]] ; %subnormal = load float, ptr @flt_pos_min_subnormal %target = fpext float 1.0 to fp128 %next = call float @nexttowardf(float %subnormal, fp128 %target) readnone ret float %next } declare double @nexttoward(double, fp128) #0 declare float @nexttowardf(float, fp128) #0 attributes #0 = { willreturn memory(errnomem: write) }