1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2 ; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4 ; This is related to https://bugs.llvm.org/show_bug.cgi?id=36682 5 6 ; All of these can be simplified to a constant true or false value. 7 ; * slt i32 %b, 0 -> false 8 ; * sgt i32 %b, -1 -> true 9 10 define i1 @i32_cast_cmp_slt_int_0_uitofp_float(i32 %i) { 11 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_float( 12 ; CHECK-NEXT: ret i1 false 13 ; 14 %f = uitofp i32 %i to float 15 %b = bitcast float %f to i32 16 %cmp = icmp slt i32 %b, 0 17 ret i1 %cmp 18 } 19 20 define <2 x i1> @i32_cast_cmp_slt_int_0_uitofp_float_vec(<2 x i32> %i) { 21 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_float_vec( 22 ; CHECK-NEXT: ret <2 x i1> zeroinitializer 23 ; 24 %f = uitofp <2 x i32> %i to <2 x float> 25 %b = bitcast <2 x float> %f to <2 x i32> 26 %cmp = icmp slt <2 x i32> %b, <i32 0, i32 0> 27 ret <2 x i1> %cmp 28 } 29 30 define <3 x i1> @i32_cast_cmp_slt_int_0_uitofp_float_vec_undef(<3 x i32> %i) { 31 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_float_vec_undef( 32 ; CHECK-NEXT: ret <3 x i1> zeroinitializer 33 ; 34 %f = uitofp <3 x i32> %i to <3 x float> 35 %b = bitcast <3 x float> %f to <3 x i32> 36 %cmp = icmp slt <3 x i32> %b, <i32 0, i32 undef, i32 0> 37 ret <3 x i1> %cmp 38 } 39 40 define i1 @i32_cast_cmp_sgt_int_m1_uitofp_float(i32 %i) { 41 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_float( 42 ; CHECK-NEXT: ret i1 true 43 ; 44 %f = uitofp i32 %i to float 45 %b = bitcast float %f to i32 46 %cmp = icmp sgt i32 %b, -1 47 ret i1 %cmp 48 } 49 50 define <2 x i1> @i32_cast_cmp_sgt_int_m1_uitofp_float_vec(<2 x i32> %i) { 51 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_float_vec( 52 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true> 53 ; 54 %f = uitofp <2 x i32> %i to <2 x float> 55 %b = bitcast <2 x float> %f to <2 x i32> 56 %cmp = icmp sgt <2 x i32> %b, <i32 -1, i32 -1> 57 ret <2 x i1> %cmp 58 } 59 60 define <3 x i1> @i32_cast_cmp_sgt_int_m1_uitofp_float_vec_undef(<3 x i32> %i) { 61 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_float_vec_undef( 62 ; CHECK-NEXT: ret <3 x i1> <i1 true, i1 true, i1 true> 63 ; 64 %f = uitofp <3 x i32> %i to <3 x float> 65 %b = bitcast <3 x float> %f to <3 x i32> 66 %cmp = icmp sgt <3 x i32> %b, <i32 -1, i32 undef, i32 -1> 67 ret <3 x i1> %cmp 68 } 69 70 define i1 @i32_cast_cmp_slt_int_0_uitofp_double(i32 %i) { 71 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_double( 72 ; CHECK-NEXT: ret i1 false 73 ; 74 %f = uitofp i32 %i to double 75 %b = bitcast double %f to i64 76 %cmp = icmp slt i64 %b, 0 77 ret i1 %cmp 78 } 79 80 define <2 x i1> @i32_cast_cmp_slt_int_0_uitofp_double_vec(<2 x i32> %i) { 81 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_double_vec( 82 ; CHECK-NEXT: ret <2 x i1> zeroinitializer 83 ; 84 %f = uitofp <2 x i32> %i to <2 x double> 85 %b = bitcast <2 x double> %f to <2 x i64> 86 %cmp = icmp slt <2 x i64> %b, <i64 0, i64 0> 87 ret <2 x i1> %cmp 88 } 89 90 define <3 x i1> @i32_cast_cmp_slt_int_0_uitofp_double_vec_undef(<3 x i32> %i) { 91 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_double_vec_undef( 92 ; CHECK-NEXT: ret <3 x i1> zeroinitializer 93 ; 94 %f = uitofp <3 x i32> %i to <3 x double> 95 %b = bitcast <3 x double> %f to <3 x i64> 96 %cmp = icmp slt <3 x i64> %b, <i64 0, i64 undef, i64 0> 97 ret <3 x i1> %cmp 98 } 99 100 define i1 @i32_cast_cmp_sgt_int_m1_uitofp_double(i32 %i) { 101 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_double( 102 ; CHECK-NEXT: ret i1 true 103 ; 104 %f = uitofp i32 %i to double 105 %b = bitcast double %f to i64 106 %cmp = icmp sgt i64 %b, -1 107 ret i1 %cmp 108 } 109 110 define <2 x i1> @i32_cast_cmp_sgt_int_m1_uitofp_double_vec(<2 x i32> %i) { 111 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_double_vec( 112 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true> 113 ; 114 %f = uitofp <2 x i32> %i to <2 x double> 115 %b = bitcast <2 x double> %f to <2 x i64> 116 %cmp = icmp sgt <2 x i64> %b, <i64 -1, i64 -1> 117 ret <2 x i1> %cmp 118 } 119 120 define <3 x i1> @i32_cast_cmp_sgt_int_m1_uitofp_double_vec_undef(<3 x i32> %i) { 121 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_double_vec_undef( 122 ; CHECK-NEXT: ret <3 x i1> <i1 true, i1 true, i1 true> 123 ; 124 %f = uitofp <3 x i32> %i to <3 x double> 125 %b = bitcast <3 x double> %f to <3 x i64> 126 %cmp = icmp sgt <3 x i64> %b, <i64 -1, i64 undef, i64 -1> 127 ret <3 x i1> %cmp 128 } 129 130 define i1 @i32_cast_cmp_slt_int_0_uitofp_half(i32 %i) { 131 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_half( 132 ; CHECK-NEXT: ret i1 false 133 ; 134 %f = uitofp i32 %i to half 135 %b = bitcast half %f to i16 136 %cmp = icmp slt i16 %b, 0 137 ret i1 %cmp 138 } 139 140 define <2 x i1> @i32_cast_cmp_slt_int_0_uitofp_half_vec(<2 x i32> %i) { 141 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_half_vec( 142 ; CHECK-NEXT: ret <2 x i1> zeroinitializer 143 ; 144 %f = uitofp <2 x i32> %i to <2 x half> 145 %b = bitcast <2 x half> %f to <2 x i16> 146 %cmp = icmp slt <2 x i16> %b, <i16 0, i16 0> 147 ret <2 x i1> %cmp 148 } 149 150 define <3 x i1> @i32_cast_cmp_slt_int_0_uitofp_half_vec_undef(<3 x i32> %i) { 151 ; CHECK-LABEL: @i32_cast_cmp_slt_int_0_uitofp_half_vec_undef( 152 ; CHECK-NEXT: ret <3 x i1> zeroinitializer 153 ; 154 %f = uitofp <3 x i32> %i to <3 x half> 155 %b = bitcast <3 x half> %f to <3 x i16> 156 %cmp = icmp slt <3 x i16> %b, <i16 0, i16 undef, i16 0> 157 ret <3 x i1> %cmp 158 } 159 160 define i1 @i32_cast_cmp_sgt_int_m1_uitofp_half(i32 %i) { 161 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_half( 162 ; CHECK-NEXT: ret i1 true 163 ; 164 %f = uitofp i32 %i to half 165 %b = bitcast half %f to i16 166 %cmp = icmp sgt i16 %b, -1 167 ret i1 %cmp 168 } 169 170 define <2 x i1> @i32_cast_cmp_sgt_int_m1_uitofp_half_vec(<2 x i32> %i) { 171 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_half_vec( 172 ; CHECK-NEXT: ret <2 x i1> <i1 true, i1 true> 173 ; 174 %f = uitofp <2 x i32> %i to <2 x half> 175 %b = bitcast <2 x half> %f to <2 x i16> 176 %cmp = icmp sgt <2 x i16> %b, <i16 -1, i16 -1> 177 ret <2 x i1> %cmp 178 } 179 180 define <3 x i1> @i32_cast_cmp_sgt_int_m1_uitofp_half_vec_undef(<3 x i32> %i) { 181 ; CHECK-LABEL: @i32_cast_cmp_sgt_int_m1_uitofp_half_vec_undef( 182 ; CHECK-NEXT: ret <3 x i1> <i1 true, i1 true, i1 true> 183 ; 184 %f = uitofp <3 x i32> %i to <3 x half> 185 %b = bitcast <3 x half> %f to <3 x i16> 186 %cmp = icmp sgt <3 x i16> %b, <i16 -1, i16 undef, i16 -1> 187 ret <3 x i1> %cmp 188 } 189