1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4; TODO: the instructions with poison operands should return poison 5 6define float @fadd_undef_op0(float %x) { 7; CHECK-LABEL: @fadd_undef_op0( 8; CHECK-NEXT: ret float 0x7FF8000000000000 9; 10 %r = fadd float undef, %x 11 ret float %r 12} 13 14define float @fadd_poison_op0(float %x) { 15; CHECK-LABEL: @fadd_poison_op0( 16; CHECK-NEXT: ret float 0x7FF8000000000000 17; 18 %r = fadd float poison, %x 19 ret float %r 20} 21 22define float @fadd_undef_op1(float %x) { 23; CHECK-LABEL: @fadd_undef_op1( 24; CHECK-NEXT: ret float 0x7FF8000000000000 25; 26 %r = fadd float %x, undef 27 ret float %r 28} 29 30define float @fadd_poison_op1(float %x) { 31; CHECK-LABEL: @fadd_poison_op1( 32; CHECK-NEXT: ret float 0x7FF8000000000000 33; 34 %r = fadd float %x, poison 35 ret float %r 36} 37 38define float @fsub_undef_op0(float %x) { 39; CHECK-LABEL: @fsub_undef_op0( 40; CHECK-NEXT: ret float 0x7FF8000000000000 41; 42 %r = fsub float undef, %x 43 ret float %r 44} 45 46define float @fsub_poison_op0(float %x) { 47; CHECK-LABEL: @fsub_poison_op0( 48; CHECK-NEXT: ret float 0x7FF8000000000000 49; 50 %r = fsub float poison, %x 51 ret float %r 52} 53 54define float @fsub_undef_op1(float %x) { 55; CHECK-LABEL: @fsub_undef_op1( 56; CHECK-NEXT: ret float 0x7FF8000000000000 57; 58 %r = fsub float %x, undef 59 ret float %r 60} 61 62define float @fsub_poison_op1(float %x) { 63; CHECK-LABEL: @fsub_poison_op1( 64; CHECK-NEXT: ret float 0x7FF8000000000000 65; 66 %r = fsub float %x, poison 67 ret float %r 68} 69 70define float @fmul_undef_op0(float %x) { 71; CHECK-LABEL: @fmul_undef_op0( 72; CHECK-NEXT: ret float 0x7FF8000000000000 73; 74 %r = fmul float undef, %x 75 ret float %r 76} 77 78define float @fmul_poison_op0(float %x) { 79; CHECK-LABEL: @fmul_poison_op0( 80; CHECK-NEXT: ret float 0x7FF8000000000000 81; 82 %r = fmul float poison, %x 83 ret float %r 84} 85 86define float @fmul_undef_op1(float %x) { 87; CHECK-LABEL: @fmul_undef_op1( 88; CHECK-NEXT: ret float 0x7FF8000000000000 89; 90 %r = fmul float %x, undef 91 ret float %r 92} 93 94define float @fmul_poison_op1(float %x) { 95; CHECK-LABEL: @fmul_poison_op1( 96; CHECK-NEXT: ret float 0x7FF8000000000000 97; 98 %r = fmul float %x, poison 99 ret float %r 100} 101 102define float @fdiv_undef_op0(float %x) { 103; CHECK-LABEL: @fdiv_undef_op0( 104; CHECK-NEXT: ret float 0x7FF8000000000000 105; 106 %r = fdiv float undef, %x 107 ret float %r 108} 109 110define float @fdiv_poison_op0(float %x) { 111; CHECK-LABEL: @fdiv_poison_op0( 112; CHECK-NEXT: ret float 0x7FF8000000000000 113; 114 %r = fdiv float poison, %x 115 ret float %r 116} 117 118define float @fdiv_undef_op1(float %x) { 119; CHECK-LABEL: @fdiv_undef_op1( 120; CHECK-NEXT: ret float 0x7FF8000000000000 121; 122 %r = fdiv float %x, undef 123 ret float %r 124} 125 126define float @fdiv_poison_op1(float %x) { 127; CHECK-LABEL: @fdiv_poison_op1( 128; CHECK-NEXT: ret float 0x7FF8000000000000 129; 130 %r = fdiv float %x, poison 131 ret float %r 132} 133 134define float @frem_undef_op0(float %x) { 135; CHECK-LABEL: @frem_undef_op0( 136; CHECK-NEXT: ret float 0x7FF8000000000000 137; 138 %r = frem float undef, %x 139 ret float %r 140} 141 142define float @frem_poison_op0(float %x) { 143; CHECK-LABEL: @frem_poison_op0( 144; CHECK-NEXT: ret float 0x7FF8000000000000 145; 146 %r = frem float poison, %x 147 ret float %r 148} 149 150define float @frem_undef_op1(float %x) { 151; CHECK-LABEL: @frem_undef_op1( 152; CHECK-NEXT: ret float 0x7FF8000000000000 153; 154 %r = frem float %x, undef 155 ret float %r 156} 157 158define float @frem_poison_op1(float %x) { 159; CHECK-LABEL: @frem_poison_op1( 160; CHECK-NEXT: ret float 0x7FF8000000000000 161; 162 %r = frem float %x, poison 163 ret float %r 164} 165 166; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage. 167 168define float @fadd_undef_op0_nnan(float %x) { 169; CHECK-LABEL: @fadd_undef_op0_nnan( 170; CHECK-NEXT: ret float undef 171; 172 %r = fadd nnan float undef, %x 173 ret float %r 174} 175 176define float @fadd_undef_op1_fast(float %x) { 177; CHECK-LABEL: @fadd_undef_op1_fast( 178; CHECK-NEXT: ret float undef 179; 180 %r = fadd fast float %x, undef 181 ret float %r 182} 183 184define float @fsub_undef_op0_fast(float %x) { 185; CHECK-LABEL: @fsub_undef_op0_fast( 186; CHECK-NEXT: ret float undef 187; 188 %r = fsub fast float undef, %x 189 ret float %r 190} 191 192define float @fsub_undef_op1_nnan(float %x) { 193; CHECK-LABEL: @fsub_undef_op1_nnan( 194; CHECK-NEXT: ret float undef 195; 196 %r = fsub nnan float %x, undef 197 ret float %r 198} 199 200define float @fmul_undef_op0_nnan(float %x) { 201; CHECK-LABEL: @fmul_undef_op0_nnan( 202; CHECK-NEXT: ret float undef 203; 204 %r = fmul nnan float undef, %x 205 ret float %r 206} 207 208define float @fmul_undef_op1_fast(float %x) { 209; CHECK-LABEL: @fmul_undef_op1_fast( 210; CHECK-NEXT: ret float undef 211; 212 %r = fmul fast float %x, undef 213 ret float %r 214} 215 216define float @fdiv_undef_op0_fast(float %x) { 217; CHECK-LABEL: @fdiv_undef_op0_fast( 218; CHECK-NEXT: ret float undef 219; 220 %r = fdiv fast float undef, %x 221 ret float %r 222} 223 224define float @fdiv_undef_op1_nnan(float %x) { 225; CHECK-LABEL: @fdiv_undef_op1_nnan( 226; CHECK-NEXT: ret float undef 227; 228 %r = fdiv nnan float %x, undef 229 ret float %r 230} 231 232define float @frem_undef_op0_nnan(float %x) { 233; CHECK-LABEL: @frem_undef_op0_nnan( 234; CHECK-NEXT: ret float undef 235; 236 %r = frem nnan float undef, %x 237 ret float %r 238} 239 240define float @frem_undef_op1_fast(float %x) { 241; CHECK-LABEL: @frem_undef_op1_fast( 242; CHECK-NEXT: ret float undef 243; 244 %r = frem fast float %x, undef 245 ret float %r 246} 247 248define double @fdiv_ninf_nan_op0(double %x) { 249; CHECK-LABEL: @fdiv_ninf_nan_op0( 250; CHECK-NEXT: ret double 0xFFF8000000000000 251; 252 %r = fdiv ninf double 0xfff8000000000000, %x 253 ret double %r 254} 255 256define double @fadd_ninf_nan_op1(double %x) { 257; CHECK-LABEL: @fadd_ninf_nan_op1( 258; CHECK-NEXT: ret double 0x7FF8000000000000 259; 260 %r = fadd ninf double %x, 0x7ff8000000000000 261 ret double %r 262} 263 264define double @fdiv_ninf_inf_op0(double %x) { 265; CHECK-LABEL: @fdiv_ninf_inf_op0( 266; CHECK-NEXT: ret double undef 267; 268 %r = fdiv ninf double 0x7ff0000000000000, %x 269 ret double %r 270} 271 272define double @fadd_ninf_inf_op1(double %x) { 273; CHECK-LABEL: @fadd_ninf_inf_op1( 274; CHECK-NEXT: ret double undef 275; 276 %r = fadd ninf double %x, 0xfff0000000000000 277 ret double %r 278} 279 280; TODO: Should simplify to inf. 281 282define double @fsub_nnan_inf_op0(double %x) { 283; CHECK-LABEL: @fsub_nnan_inf_op0( 284; CHECK-NEXT: [[R:%.*]] = fsub nnan double 0x7FF0000000000000, [[X:%.*]] 285; CHECK-NEXT: ret double [[R]] 286; 287 %r = fsub nnan double 0x7ff0000000000000, %x 288 ret double %r 289} 290 291; TODO: Should simplify to -inf. 292 293define double @fmul_nnan_inf_op1(double %x) { 294; CHECK-LABEL: @fmul_nnan_inf_op1( 295; CHECK-NEXT: [[R:%.*]] = fmul nnan double [[X:%.*]], 0xFFF0000000000000 296; CHECK-NEXT: ret double [[R]] 297; 298 %r = fmul nnan double %x, 0xfff0000000000000 299 ret double %r 300} 301