|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt < %s -instsimplify -S | FileCheck %s |
| 3 | + |
| 4 | +; |
| 5 | +; constrained fadd |
| 6 | +; |
| 7 | + |
| 8 | +; |
| 9 | +; fadd X, -0 ==> X |
| 10 | +; |
| 11 | + |
| 12 | +define float @fadd_x_n0_defaultenv(float %a) #0 { |
| 13 | +; CHECK-LABEL: @fadd_x_n0_defaultenv( |
| 14 | +; CHECK-NEXT: ret float [[A:%.*]] |
| 15 | +; |
| 16 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 17 | + ret float %ret |
| 18 | +} |
| 19 | + |
| 20 | +define <2 x float> @fadd_vec_x_n0_defaultenv(<2 x float> %a) #0 { |
| 21 | +; CHECK-LABEL: @fadd_vec_x_n0_defaultenv( |
| 22 | +; CHECK-NEXT: ret <2 x float> [[A:%.*]] |
| 23 | +; |
| 24 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 25 | + ret <2 x float> %ret |
| 26 | +} |
| 27 | + |
| 28 | +define float @fadd_x_n0_ebmaytrap(float %a) #0 { |
| 29 | +; CHECK-LABEL: @fadd_x_n0_ebmaytrap( |
| 30 | +; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0:[0-9]+]] |
| 31 | +; CHECK-NEXT: ret float [[RET]] |
| 32 | +; |
| 33 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 34 | + ret float %ret |
| 35 | +} |
| 36 | + |
| 37 | +define <2 x float> @fadd_vec_x_n0_ebmaytrap(<2 x float> %a) #0 { |
| 38 | +; CHECK-LABEL: @fadd_vec_x_n0_ebmaytrap( |
| 39 | +; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 40 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 41 | +; |
| 42 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 43 | + ret <2 x float> %ret |
| 44 | +} |
| 45 | + |
| 46 | +define float @fadd_x_n0_ebstrict(float %a) #0 { |
| 47 | +; CHECK-LABEL: @fadd_x_n0_ebstrict( |
| 48 | +; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 49 | +; CHECK-NEXT: ret float [[RET]] |
| 50 | +; |
| 51 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 52 | + ret float %ret |
| 53 | +} |
| 54 | + |
| 55 | +define <2 x float> @fadd_vec_x_n0_ebstrict(<2 x float> %a) #0 { |
| 56 | +; CHECK-LABEL: @fadd_vec_x_n0_ebstrict( |
| 57 | +; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 58 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 59 | +; |
| 60 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 61 | + ret <2 x float> %ret |
| 62 | +} |
| 63 | + |
| 64 | +define float @fadd_x_n0_neginf(float %a) #0 { |
| 65 | +; CHECK-LABEL: @fadd_x_n0_neginf( |
| 66 | +; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.downward", metadata !"fpexcept.ignore") #[[ATTR0]] |
| 67 | +; CHECK-NEXT: ret float [[RET]] |
| 68 | +; |
| 69 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.downward", metadata !"fpexcept.ignore") #0 |
| 70 | + ret float %ret |
| 71 | +} |
| 72 | + |
| 73 | +define <2 x float> @fadd_vec_x_n0_neginf(<2 x float> %a) #0 { |
| 74 | +; CHECK-LABEL: @fadd_vec_x_n0_neginf( |
| 75 | +; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.downward", metadata !"fpexcept.ignore") #[[ATTR0]] |
| 76 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 77 | +; |
| 78 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.downward", metadata !"fpexcept.ignore") #0 |
| 79 | + ret <2 x float> %ret |
| 80 | +} |
| 81 | + |
| 82 | +define float @fadd_x_n0_dynamic(float %a) #0 { |
| 83 | +; CHECK-LABEL: @fadd_x_n0_dynamic( |
| 84 | +; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]] |
| 85 | +; CHECK-NEXT: ret float [[RET]] |
| 86 | +; |
| 87 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0 |
| 88 | + ret float %ret |
| 89 | +} |
| 90 | + |
| 91 | +define <2 x float> @fadd_vec_x_n0_dynamic(<2 x float> %a) #0 { |
| 92 | +; CHECK-LABEL: @fadd_vec_x_n0_dynamic( |
| 93 | +; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.dynamic", metadata !"fpexcept.ignore") #[[ATTR0]] |
| 94 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 95 | +; |
| 96 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.dynamic", metadata !"fpexcept.ignore") #0 |
| 97 | + ret <2 x float> %ret |
| 98 | +} |
| 99 | + |
| 100 | +; The rounding mode here needs to not be { tonearest, downward, dynamic }. |
| 101 | +; Test one of the remaining rounding modes and the rest will be fine. |
| 102 | +define float @fadd_x_n0_towardzero(float %a) #0 { |
| 103 | +; CHECK-LABEL: @fadd_x_n0_towardzero( |
| 104 | +; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.towardzero", metadata !"fpexcept.ignore") #[[ATTR0]] |
| 105 | +; CHECK-NEXT: ret float [[RET]] |
| 106 | +; |
| 107 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.towardzero", metadata !"fpexcept.ignore") #0 |
| 108 | + ret float %ret |
| 109 | +} |
| 110 | + |
| 111 | +; The rounding mode here needs to not be { tonearest, downward, dynamic }. |
| 112 | +; Test one of the remaining rounding modes and the rest will be fine. |
| 113 | +define <2 x float> @fadd_vec_x_n0_towardzero(<2 x float> %a) #0 { |
| 114 | +; CHECK-LABEL: @fadd_vec_x_n0_towardzero( |
| 115 | +; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.towardzero", metadata !"fpexcept.ignore") #[[ATTR0]] |
| 116 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 117 | +; |
| 118 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.towardzero", metadata !"fpexcept.ignore") #0 |
| 119 | + ret <2 x float> %ret |
| 120 | +} |
| 121 | + |
| 122 | +define float @fadd_nnan_x_n0_ebstrict(float %a) #0 { |
| 123 | +; CHECK-LABEL: @fadd_nnan_x_n0_ebstrict( |
| 124 | +; CHECK-NEXT: [[RET:%.*]] = call nnan float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 125 | +; CHECK-NEXT: ret float [[RET]] |
| 126 | +; |
| 127 | + %ret = call nnan float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 128 | + ret float %ret |
| 129 | +} |
| 130 | + |
| 131 | +define <2 x float> @fadd_vec_nnan_x_n0_ebstrict(<2 x float> %a) #0 { |
| 132 | +; CHECK-LABEL: @fadd_vec_nnan_x_n0_ebstrict( |
| 133 | +; CHECK-NEXT: [[RET:%.*]] = call nnan <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 134 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 135 | +; |
| 136 | + %ret = call nnan <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 137 | + ret <2 x float> %ret |
| 138 | +} |
| 139 | + |
| 140 | +; Test with a fast math flag set but that flag is not "nnan". |
| 141 | +define float @fadd_ninf_x_n0_ebstrict(float %a) #0 { |
| 142 | +; CHECK-LABEL: @fadd_ninf_x_n0_ebstrict( |
| 143 | +; CHECK-NEXT: [[RET:%.*]] = call ninf float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float -0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 144 | +; CHECK-NEXT: ret float [[RET]] |
| 145 | +; |
| 146 | + %ret = call ninf float @llvm.experimental.constrained.fadd.f32(float %a, float -0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 147 | + ret float %ret |
| 148 | +} |
| 149 | + |
| 150 | +; Test with a fast math flag set but that flag is not "nnan". |
| 151 | +define <2 x float> @fadd_vec_ninf_x_n0_ebstrict(<2 x float> %a) #0 { |
| 152 | +; CHECK-LABEL: @fadd_vec_ninf_x_n0_ebstrict( |
| 153 | +; CHECK-NEXT: [[RET:%.*]] = call ninf <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> <float -0.000000e+00, float -0.000000e+00>, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 154 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 155 | +; |
| 156 | + %ret = call ninf <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float><float -0.0, float -0.0>, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 157 | + ret <2 x float> %ret |
| 158 | +} |
| 159 | + |
| 160 | +define float @fadd_n0_x_defaultenv(float %a) #0 { |
| 161 | +; CHECK-LABEL: @fadd_n0_x_defaultenv( |
| 162 | +; CHECK-NEXT: ret float [[A:%.*]] |
| 163 | +; |
| 164 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float -0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 165 | + ret float %ret |
| 166 | +} |
| 167 | + |
| 168 | +define <2 x float> @fadd_vec_n0_x_defaultenv(<2 x float> %a) #0 { |
| 169 | +; CHECK-LABEL: @fadd_vec_n0_x_defaultenv( |
| 170 | +; CHECK-NEXT: ret <2 x float> [[A:%.*]] |
| 171 | +; |
| 172 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float -0.0, float -0.0>, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 173 | + ret <2 x float> %ret |
| 174 | +} |
| 175 | + |
| 176 | +; TODO: Canonicalize the order of the arguments. Then this will fire. |
| 177 | +define float @fadd_n0_x_ebmaytrap(float %a) #0 { |
| 178 | +; CHECK-LABEL: @fadd_n0_x_ebmaytrap( |
| 179 | +; CHECK-NEXT: [[RET:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float -0.000000e+00, float [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 180 | +; CHECK-NEXT: ret float [[RET]] |
| 181 | +; |
| 182 | + %ret = call float @llvm.experimental.constrained.fadd.f32(float -0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 183 | + ret float %ret |
| 184 | +} |
| 185 | + |
| 186 | +; TODO: Canonicalize the order of the arguments. Then this will fire. |
| 187 | +define <2 x float> @fadd_vec_n0_x_ebmaytrap(<2 x float> %a) #0 { |
| 188 | +; CHECK-LABEL: @fadd_vec_n0_x_ebmaytrap( |
| 189 | +; CHECK-NEXT: [[RET:%.*]] = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> <float -0.000000e+00, float -0.000000e+00>, <2 x float> [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 190 | +; CHECK-NEXT: ret <2 x float> [[RET]] |
| 191 | +; |
| 192 | + %ret = call <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float><float -0.0, float -0.0>, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 193 | + ret <2 x float> %ret |
| 194 | +} |
| 195 | + |
| 196 | +; |
| 197 | +; fadd X, 0 ==> X, when we know X is not -0 |
| 198 | +; |
| 199 | + |
| 200 | +define float @fold_fadd_nsz_x_0_defaultenv(float %a) #0 { |
| 201 | +; CHECK-LABEL: @fold_fadd_nsz_x_0_defaultenv( |
| 202 | +; CHECK-NEXT: ret float [[A:%.*]] |
| 203 | +; |
| 204 | + %add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 205 | + ret float %add |
| 206 | +} |
| 207 | + |
| 208 | +define <2 x float> @fold_fadd_vec_nsz_x_0_defaultenv(<2 x float> %a) #0 { |
| 209 | +; CHECK-LABEL: @fold_fadd_vec_nsz_x_0_defaultenv( |
| 210 | +; CHECK-NEXT: ret <2 x float> [[A:%.*]] |
| 211 | +; |
| 212 | + %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 213 | + ret <2 x float> %add |
| 214 | +} |
| 215 | + |
| 216 | +define float @fold_fadd_nsz_x_0_ebmaytrap(float %a) #0 { |
| 217 | +; CHECK-LABEL: @fold_fadd_nsz_x_0_ebmaytrap( |
| 218 | +; CHECK-NEXT: [[ADD:%.*]] = call nsz float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float 0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 219 | +; CHECK-NEXT: ret float [[ADD]] |
| 220 | +; |
| 221 | + %add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 222 | + ret float %add |
| 223 | +} |
| 224 | + |
| 225 | +define <2 x float> @fold_fadd_vec_nsz_x_0_ebmaytrap(<2 x float> %a) #0 { |
| 226 | +; CHECK-LABEL: @fold_fadd_vec_nsz_x_0_ebmaytrap( |
| 227 | +; CHECK-NEXT: [[ADD:%.*]] = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 228 | +; CHECK-NEXT: ret <2 x float> [[ADD]] |
| 229 | +; |
| 230 | + %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 231 | + ret <2 x float> %add |
| 232 | +} |
| 233 | + |
| 234 | +define float @fold_fadd_nsz_x_0_ebstrict(float %a) #0 { |
| 235 | +; CHECK-LABEL: @fold_fadd_nsz_x_0_ebstrict( |
| 236 | +; CHECK-NEXT: [[ADD:%.*]] = call nsz float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float 0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 237 | +; CHECK-NEXT: ret float [[ADD]] |
| 238 | +; |
| 239 | + %add = call nsz float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 240 | + ret float %add |
| 241 | +} |
| 242 | + |
| 243 | +define <2 x float> @fold_fadd_vec_nsz_x_0_ebstrict(<2 x float> %a) #0 { |
| 244 | +; CHECK-LABEL: @fold_fadd_vec_nsz_x_0_ebstrict( |
| 245 | +; CHECK-NEXT: [[ADD:%.*]] = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 246 | +; CHECK-NEXT: ret <2 x float> [[ADD]] |
| 247 | +; |
| 248 | + %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 249 | + ret <2 x float> %add |
| 250 | +} |
| 251 | + |
| 252 | +define float @fold_fadd_nsz_nnan_x_0_ebstrict(float %a) #0 { |
| 253 | +; CHECK-LABEL: @fold_fadd_nsz_nnan_x_0_ebstrict( |
| 254 | +; CHECK-NEXT: [[ADD:%.*]] = call nnan nsz float @llvm.experimental.constrained.fadd.f32(float [[A:%.*]], float 0.000000e+00, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 255 | +; CHECK-NEXT: ret float [[ADD]] |
| 256 | +; |
| 257 | + %add = call nsz nnan float @llvm.experimental.constrained.fadd.f32(float %a, float 0.0, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 258 | + ret float %add |
| 259 | +} |
| 260 | + |
| 261 | +define <2 x float> @fold_fadd_vec_nsz_nnan_x_0_ebstrict(<2 x float> %a) #0 { |
| 262 | +; CHECK-LABEL: @fold_fadd_vec_nsz_nnan_x_0_ebstrict( |
| 263 | +; CHECK-NEXT: [[ADD:%.*]] = call nnan nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> [[A:%.*]], <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 264 | +; CHECK-NEXT: ret <2 x float> [[ADD]] |
| 265 | +; |
| 266 | + %add = call nsz nnan <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> %a, <2 x float> zeroinitializer, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 267 | + ret <2 x float> %add |
| 268 | +} |
| 269 | + |
| 270 | +define float @fold_fadd_nsz_0_x_defaultenv(float %a) #0 { |
| 271 | +; CHECK-LABEL: @fold_fadd_nsz_0_x_defaultenv( |
| 272 | +; CHECK-NEXT: ret float [[A:%.*]] |
| 273 | +; |
| 274 | + %add = call nsz float @llvm.experimental.constrained.fadd.f32(float 0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 275 | + ret float %add |
| 276 | +} |
| 277 | + |
| 278 | +define <2 x float> @fold_fadd_vec_nsz_0_x_defaultenv(<2 x float> %a) #0 { |
| 279 | +; CHECK-LABEL: @fold_fadd_vec_nsz_0_x_defaultenv( |
| 280 | +; CHECK-NEXT: ret <2 x float> [[A:%.*]] |
| 281 | +; |
| 282 | + %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> zeroinitializer, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.ignore") #0 |
| 283 | + ret <2 x float> %add |
| 284 | +} |
| 285 | + |
| 286 | +; TODO: Canonicalize the order of the arguments. Then this will fire. |
| 287 | +define float @fold_fadd_nsz_0_x_ebmaytrap(float %a) #0 { |
| 288 | +; CHECK-LABEL: @fold_fadd_nsz_0_x_ebmaytrap( |
| 289 | +; CHECK-NEXT: [[ADD:%.*]] = call nsz float @llvm.experimental.constrained.fadd.f32(float 0.000000e+00, float [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 290 | +; CHECK-NEXT: ret float [[ADD]] |
| 291 | +; |
| 292 | + %add = call nsz float @llvm.experimental.constrained.fadd.f32(float 0.0, float %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 293 | + ret float %add |
| 294 | +} |
| 295 | + |
| 296 | +; TODO: Canonicalize the order of the arguments. Then this will fire. |
| 297 | +define <2 x float> @fold_fadd_vec_nsz_0_x_ebmaytrap(<2 x float> %a) #0 { |
| 298 | +; CHECK-LABEL: @fold_fadd_vec_nsz_0_x_ebmaytrap( |
| 299 | +; CHECK-NEXT: [[ADD:%.*]] = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> zeroinitializer, <2 x float> [[A:%.*]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR0]] |
| 300 | +; CHECK-NEXT: ret <2 x float> [[ADD]] |
| 301 | +; |
| 302 | + %add = call nsz <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float> zeroinitializer, <2 x float> %a, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 303 | + ret <2 x float> %add |
| 304 | +} |
| 305 | + |
| 306 | +; |
| 307 | +; fadd with NaNs |
| 308 | +; |
| 309 | + |
| 310 | +define float @fold_fadd_qnan_qnan_ebmaytrap() #0 { |
| 311 | +; CHECK-LABEL: @fold_fadd_qnan_qnan_ebmaytrap( |
| 312 | +; CHECK-NEXT: ret float 0x7FF8000000000000 |
| 313 | +; |
| 314 | + %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff8000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 315 | + ret float %add |
| 316 | +} |
| 317 | + |
| 318 | +define float @fold_fadd_qnan_qnan_ebstrict() #0 { |
| 319 | +; CHECK-LABEL: @fold_fadd_qnan_qnan_ebstrict( |
| 320 | +; CHECK-NEXT: [[ADD:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float 0x7FF8000000000000, float 0x7FF8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 321 | +; CHECK-NEXT: ret float [[ADD]] |
| 322 | +; |
| 323 | + %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff8000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 324 | + ret float %add |
| 325 | +} |
| 326 | + |
| 327 | +define float @fold_fadd_snan_qnan_ebmaytrap() #0 { |
| 328 | +; CHECK-LABEL: @fold_fadd_snan_qnan_ebmaytrap( |
| 329 | +; CHECK-NEXT: ret float 0x7FF4000000000000 |
| 330 | +; |
| 331 | + %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff4000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.maytrap") #0 |
| 332 | + ret float %add |
| 333 | +} |
| 334 | + |
| 335 | +define float @fold_fadd_snan_qnan_ebstrict() #0 { |
| 336 | +; CHECK-LABEL: @fold_fadd_snan_qnan_ebstrict( |
| 337 | +; CHECK-NEXT: [[ADD:%.*]] = call float @llvm.experimental.constrained.fadd.f32(float 0x7FF4000000000000, float 0x7FF8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #[[ATTR0]] |
| 338 | +; CHECK-NEXT: ret float [[ADD]] |
| 339 | +; |
| 340 | + %add = call float @llvm.experimental.constrained.fadd.f32(float 0x7ff4000000000000, float 0x7ff8000000000000, metadata !"round.tonearest", metadata !"fpexcept.strict") #0 |
| 341 | + ret float %add |
| 342 | +} |
| 343 | + |
| 344 | +declare float @llvm.experimental.constrained.fadd.f32(float, float, metadata, metadata) #0 |
| 345 | +declare <2 x float> @llvm.experimental.constrained.fadd.v2f32(<2 x float>, <2 x float>, metadata, metadata) #0 |
| 346 | + |
| 347 | +attributes #0 = { strictfp } |
0 commit comments