Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: opt < %s -instcombine -S | FileCheck %s |
| 3 | |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 4 | ; This is related to https://bugs.llvm.org/show_bug.cgi?id=36682 |
| 5 | |
| 6 | ; FIXME: *all* of these are true tests. |
| 7 | ; In *all* of these, uitofp and bitcast should be instcombine'd out. |
| 8 | |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 9 | ; FIXME: icmp eq/ne does not ignore undef elements in vectors. |
| 10 | |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 11 | define i1 @i32_cast_cmp_eq_int_0_uitofp_float(i32 %i) { |
| 12 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 13 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0 |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 14 | ; CHECK-NEXT: ret i1 [[CMP]] |
| 15 | ; |
| 16 | %f = uitofp i32 %i to float |
| 17 | %b = bitcast float %f to i32 |
| 18 | %cmp = icmp eq i32 %b, 0 |
| 19 | ret i1 %cmp |
| 20 | } |
| 21 | |
| 22 | define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec(<2 x i32> %i) { |
| 23 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 24 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 25 | ; CHECK-NEXT: ret <2 x i1> [[CMP]] |
| 26 | ; |
| 27 | %f = uitofp <2 x i32> %i to <2 x float> |
| 28 | %b = bitcast <2 x float> %f to <2 x i32> |
| 29 | %cmp = icmp eq <2 x i32> %b, <i32 0, i32 0> |
| 30 | ret <2 x i1> %cmp |
| 31 | } |
| 32 | |
| 33 | define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef(<3 x i32> %i) { |
| 34 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_float_vec_undef( |
| 35 | ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x float> |
| 36 | ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <3 x i32> |
| 37 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i32> [[B]], <i32 0, i32 undef, i32 0> |
| 38 | ; CHECK-NEXT: ret <3 x i1> [[CMP]] |
| 39 | ; |
| 40 | %f = uitofp <3 x i32> %i to <3 x float> |
| 41 | %b = bitcast <3 x float> %f to <3 x i32> |
| 42 | %cmp = icmp eq <3 x i32> %b, <i32 0, i32 undef, i32 0> |
| 43 | ret <3 x i1> %cmp |
| 44 | } |
| 45 | |
| 46 | define i1 @i32_cast_cmp_ne_int_0_uitofp_float(i32 %i) { |
| 47 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 48 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0 |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 49 | ; CHECK-NEXT: ret i1 [[CMP]] |
| 50 | ; |
| 51 | %f = uitofp i32 %i to float |
| 52 | %b = bitcast float %f to i32 |
| 53 | %cmp = icmp ne i32 %b, 0 |
| 54 | ret i1 %cmp |
| 55 | } |
| 56 | |
| 57 | define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec(<2 x i32> %i) { |
| 58 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 59 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 60 | ; CHECK-NEXT: ret <2 x i1> [[CMP]] |
| 61 | ; |
| 62 | %f = uitofp <2 x i32> %i to <2 x float> |
| 63 | %b = bitcast <2 x float> %f to <2 x i32> |
| 64 | %cmp = icmp ne <2 x i32> %b, <i32 0, i32 0> |
| 65 | ret <2 x i1> %cmp |
| 66 | } |
| 67 | |
| 68 | define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef(<3 x i32> %i) { |
| 69 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_float_vec_undef( |
| 70 | ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x float> |
| 71 | ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x float> [[F]] to <3 x i32> |
| 72 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i32> [[B]], <i32 0, i32 undef, i32 0> |
| 73 | ; CHECK-NEXT: ret <3 x i1> [[CMP]] |
| 74 | ; |
| 75 | %f = uitofp <3 x i32> %i to <3 x float> |
| 76 | %b = bitcast <3 x float> %f to <3 x i32> |
| 77 | %cmp = icmp ne <3 x i32> %b, <i32 0, i32 undef, i32 0> |
| 78 | ret <3 x i1> %cmp |
| 79 | } |
| 80 | |
| 81 | define i1 @i32_cast_cmp_eq_int_0_uitofp_double(i32 %i) { |
| 82 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 83 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0 |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 84 | ; CHECK-NEXT: ret i1 [[CMP]] |
| 85 | ; |
| 86 | %f = uitofp i32 %i to double |
| 87 | %b = bitcast double %f to i64 |
| 88 | %cmp = icmp eq i64 %b, 0 |
| 89 | ret i1 %cmp |
| 90 | } |
| 91 | |
| 92 | define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec(<2 x i32> %i) { |
| 93 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 94 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 95 | ; CHECK-NEXT: ret <2 x i1> [[CMP]] |
| 96 | ; |
| 97 | %f = uitofp <2 x i32> %i to <2 x double> |
| 98 | %b = bitcast <2 x double> %f to <2 x i64> |
| 99 | %cmp = icmp eq <2 x i64> %b, <i64 0, i64 0> |
| 100 | ret <2 x i1> %cmp |
| 101 | } |
| 102 | |
| 103 | define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef(<3 x i32> %i) { |
| 104 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_double_vec_undef( |
| 105 | ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x double> |
| 106 | ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x double> [[F]] to <3 x i64> |
| 107 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i64> [[B]], <i64 0, i64 undef, i64 0> |
| 108 | ; CHECK-NEXT: ret <3 x i1> [[CMP]] |
| 109 | ; |
| 110 | %f = uitofp <3 x i32> %i to <3 x double> |
| 111 | %b = bitcast <3 x double> %f to <3 x i64> |
| 112 | %cmp = icmp eq <3 x i64> %b, <i64 0, i64 undef, i64 0> |
| 113 | ret <3 x i1> %cmp |
| 114 | } |
| 115 | |
| 116 | define i1 @i32_cast_cmp_ne_int_0_uitofp_double(i32 %i) { |
| 117 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 118 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0 |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 119 | ; CHECK-NEXT: ret i1 [[CMP]] |
| 120 | ; |
| 121 | %f = uitofp i32 %i to double |
| 122 | %b = bitcast double %f to i64 |
| 123 | %cmp = icmp ne i64 %b, 0 |
| 124 | ret i1 %cmp |
| 125 | } |
| 126 | |
| 127 | define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec(<2 x i32> %i) { |
| 128 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 129 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 130 | ; CHECK-NEXT: ret <2 x i1> [[CMP]] |
| 131 | ; |
| 132 | %f = uitofp <2 x i32> %i to <2 x double> |
| 133 | %b = bitcast <2 x double> %f to <2 x i64> |
| 134 | %cmp = icmp ne <2 x i64> %b, <i64 0, i64 0> |
| 135 | ret <2 x i1> %cmp |
| 136 | } |
| 137 | |
| 138 | define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef(<3 x i32> %i) { |
| 139 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_double_vec_undef( |
| 140 | ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x double> |
| 141 | ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x double> [[F]] to <3 x i64> |
| 142 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i64> [[B]], <i64 0, i64 undef, i64 0> |
| 143 | ; CHECK-NEXT: ret <3 x i1> [[CMP]] |
| 144 | ; |
| 145 | %f = uitofp <3 x i32> %i to <3 x double> |
| 146 | %b = bitcast <3 x double> %f to <3 x i64> |
| 147 | %cmp = icmp ne <3 x i64> %b, <i64 0, i64 undef, i64 0> |
| 148 | ret <3 x i1> %cmp |
| 149 | } |
| 150 | |
| 151 | define i1 @i32_cast_cmp_eq_int_0_uitofp_half(i32 %i) { |
| 152 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 153 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], 0 |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 154 | ; CHECK-NEXT: ret i1 [[CMP]] |
| 155 | ; |
| 156 | %f = uitofp i32 %i to half |
| 157 | %b = bitcast half %f to i16 |
| 158 | %cmp = icmp eq i16 %b, 0 |
| 159 | ret i1 %cmp |
| 160 | } |
| 161 | |
| 162 | define <2 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec(<2 x i32> %i) { |
| 163 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 164 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <2 x i32> [[I:%.*]], zeroinitializer |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 165 | ; CHECK-NEXT: ret <2 x i1> [[CMP]] |
| 166 | ; |
| 167 | %f = uitofp <2 x i32> %i to <2 x half> |
| 168 | %b = bitcast <2 x half> %f to <2 x i16> |
| 169 | %cmp = icmp eq <2 x i16> %b, <i16 0, i16 0> |
| 170 | ret <2 x i1> %cmp |
| 171 | } |
| 172 | |
| 173 | define <3 x i1> @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef(<3 x i32> %i) { |
| 174 | ; CHECK-LABEL: @i32_cast_cmp_eq_int_0_uitofp_half_vec_undef( |
| 175 | ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x half> |
| 176 | ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x half> [[F]] to <3 x i16> |
| 177 | ; CHECK-NEXT: [[CMP:%.*]] = icmp eq <3 x i16> [[B]], <i16 0, i16 undef, i16 0> |
| 178 | ; CHECK-NEXT: ret <3 x i1> [[CMP]] |
| 179 | ; |
| 180 | %f = uitofp <3 x i32> %i to <3 x half> |
| 181 | %b = bitcast <3 x half> %f to <3 x i16> |
| 182 | %cmp = icmp eq <3 x i16> %b, <i16 0, i16 undef, i16 0> |
| 183 | ret <3 x i1> %cmp |
| 184 | } |
| 185 | |
| 186 | define i1 @i32_cast_cmp_ne_int_0_uitofp_half(i32 %i) { |
| 187 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 188 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I:%.*]], 0 |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 189 | ; CHECK-NEXT: ret i1 [[CMP]] |
| 190 | ; |
| 191 | %f = uitofp i32 %i to half |
| 192 | %b = bitcast half %f to i16 |
| 193 | %cmp = icmp ne i16 %b, 0 |
| 194 | ret i1 %cmp |
| 195 | } |
| 196 | |
| 197 | define <2 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec(<2 x i32> %i) { |
| 198 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec( |
Roman Lebedev | e6da306 | 2018-03-18 15:53:02 +0000 | [diff] [blame^] | 199 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <2 x i32> [[I:%.*]], zeroinitializer |
Roman Lebedev | 6ab6035 | 2018-03-14 17:31:03 +0000 | [diff] [blame] | 200 | ; CHECK-NEXT: ret <2 x i1> [[CMP]] |
| 201 | ; |
| 202 | %f = uitofp <2 x i32> %i to <2 x half> |
| 203 | %b = bitcast <2 x half> %f to <2 x i16> |
| 204 | %cmp = icmp ne <2 x i16> %b, <i16 0, i16 0> |
| 205 | ret <2 x i1> %cmp |
| 206 | } |
| 207 | |
| 208 | define <3 x i1> @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef(<3 x i32> %i) { |
| 209 | ; CHECK-LABEL: @i32_cast_cmp_ne_int_0_uitofp_half_vec_undef( |
| 210 | ; CHECK-NEXT: [[F:%.*]] = uitofp <3 x i32> [[I:%.*]] to <3 x half> |
| 211 | ; CHECK-NEXT: [[B:%.*]] = bitcast <3 x half> [[F]] to <3 x i16> |
| 212 | ; CHECK-NEXT: [[CMP:%.*]] = icmp ne <3 x i16> [[B]], <i16 0, i16 undef, i16 0> |
| 213 | ; CHECK-NEXT: ret <3 x i1> [[CMP]] |
| 214 | ; |
| 215 | %f = uitofp <3 x i32> %i to <3 x half> |
| 216 | %b = bitcast <3 x half> %f to <3 x i16> |
| 217 | %cmp = icmp ne <3 x i16> %b, <i16 0, i16 undef, i16 0> |
| 218 | ret <3 x i1> %cmp |
| 219 | } |