1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instsimplify -S | FileCheck %s 3 4; Default NaN constant 5 6define double @fadd_nan_op0(double %x) { 7; CHECK-LABEL: @fadd_nan_op0( 8; CHECK-NEXT: ret double 0x7FF8000000000000 9; 10 %r = fadd double 0x7FF8000000000000, %x 11 ret double %r 12} 13 14; Sign bit is set 15 16define double @fadd_nan_op1(double %x) { 17; CHECK-LABEL: @fadd_nan_op1( 18; CHECK-NEXT: ret double 0xFFF8000000000000 19; 20 %r = fadd double %x, 0xFFF8000000000000 21 ret double %r 22} 23 24; Non-zero payload 25 26define float @fsub_nan_op0(float %x) { 27; CHECK-LABEL: @fsub_nan_op0( 28; CHECK-NEXT: ret float 0x7FFFFF0000000000 29; 30 %r = fsub float 0x7FFFFF0000000000, %x 31 ret float %r 32} 33 34; Signaling 35 36define float @fsub_nan_op1(float %x) { 37; CHECK-LABEL: @fsub_nan_op1( 38; CHECK-NEXT: ret float 0x7FF1000000000000 39; 40 %r = fsub float %x, 0x7FF1000000000000 41 ret float %r 42} 43 44; Signaling and signed 45 46define double @fmul_nan_op0(double %x) { 47; CHECK-LABEL: @fmul_nan_op0( 48; CHECK-NEXT: ret double 0xFFF0000000000001 49; 50 %r = fmul double 0xFFF0000000000001, %x 51 ret double %r 52} 53 54; Vector type 55 56define <2 x float> @fmul_nan_op1(<2 x float> %x) { 57; CHECK-LABEL: @fmul_nan_op1( 58; CHECK-NEXT: ret <2 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000> 59; 60 %r = fmul <2 x float> %x, <float 0x7FF8000000000000, float 0x7FF8000000000000> 61 ret <2 x float> %r 62} 63 64; Vector signed and non-zero payload 65 66define <2 x double> @fdiv_nan_op0(<2 x double> %x) { 67; CHECK-LABEL: @fdiv_nan_op0( 68; CHECK-NEXT: ret <2 x double> <double 0xFFF800000000000F, double 0xFFF800000000000F> 69; 70 %r = fdiv <2 x double> <double 0xFFF800000000000F, double 0xFFF800000000000F>, %x 71 ret <2 x double> %r 72} 73 74; Vector with different NaN constant elements 75 76define <2 x half> @fdiv_nan_op1(<2 x half> %x) { 77; CHECK-LABEL: @fdiv_nan_op1( 78; CHECK-NEXT: ret <2 x half> <half 0xH7FFF, half 0xHFF00> 79; 80 %r = fdiv <2 x half> %x, <half 0xH7FFF, half 0xHFF00> 81 ret <2 x half> %r 82} 83 84; Vector with undef element 85 86define <2 x double> @frem_nan_op0(<2 x double> %x) { 87; CHECK-LABEL: @frem_nan_op0( 88; CHECK-NEXT: ret <2 x double> <double 0x7FF8000000000000, double 0x7FF8000000000000> 89; 90 %r = frem <2 x double> <double 0xFFFF000000000000, double undef>, %x 91 ret <2 x double> %r 92} 93 94define float @frem_nan_op1(float %x) { 95; CHECK-LABEL: @frem_nan_op1( 96; CHECK-NEXT: ret float 0x7FF8000000000000 97; 98 %r = frem float %x, 0x7FF8000000000000 99 ret float %r 100} 101 102; Special-case: fneg must only change the sign bit (this is handled by constant folding). 103 104define double @fneg_nan_1(double %x) { 105; CHECK-LABEL: @fneg_nan_1( 106; CHECK-NEXT: ret double 0xFFFABCDEF0123456 107; 108 %r = fsub double -0.0, 0x7FFABCDEF0123456 109 ret double %r 110} 111 112define <2 x double> @fneg_nan_2(<2 x double> %x) { 113; CHECK-LABEL: @fneg_nan_2( 114; CHECK-NEXT: ret <2 x double> <double 0x7FF1234567890ABC, double 0xFFF0000000000001> 115; 116 %r = fsub <2 x double> <double -0.0, double -0.0>, <double 0xFFF1234567890ABC, double 0x7FF0000000000001> 117 ret <2 x double> %r 118} 119 120; Repeat all tests with fast-math-flags. Alternate 'nnan' and 'fast' for more coverage. 121 122define float @fadd_nan_op0_nnan(float %x) { 123; CHECK-LABEL: @fadd_nan_op0_nnan( 124; CHECK-NEXT: ret float 0x7FF8000000000000 125; 126 %r = fadd nnan float 0x7FF8000000000000, %x 127 ret float %r 128} 129 130define float @fadd_nan_op1_fast(float %x) { 131; CHECK-LABEL: @fadd_nan_op1_fast( 132; CHECK-NEXT: ret float 0x7FF8000000000000 133; 134 %r = fadd fast float %x, 0x7FF8000000000000 135 ret float %r 136} 137 138define float @fsub_nan_op0_fast(float %x) { 139; CHECK-LABEL: @fsub_nan_op0_fast( 140; CHECK-NEXT: ret float 0x7FF8000000000000 141; 142 %r = fsub fast float 0x7FF8000000000000, %x 143 ret float %r 144} 145 146define float @fsub_nan_op1_nnan(float %x) { 147; CHECK-LABEL: @fsub_nan_op1_nnan( 148; CHECK-NEXT: ret float 0x7FF8000000000000 149; 150 %r = fsub nnan float %x, 0x7FF8000000000000 151 ret float %r 152} 153 154define float @fmul_nan_op0_nnan(float %x) { 155; CHECK-LABEL: @fmul_nan_op0_nnan( 156; CHECK-NEXT: ret float 0x7FF8000000000000 157; 158 %r = fmul nnan float 0x7FF8000000000000, %x 159 ret float %r 160} 161 162define float @fmul_nan_op1_fast(float %x) { 163; CHECK-LABEL: @fmul_nan_op1_fast( 164; CHECK-NEXT: ret float 0x7FF8000000000000 165; 166 %r = fmul fast float %x, 0x7FF8000000000000 167 ret float %r 168} 169 170define float @fdiv_nan_op0_fast(float %x) { 171; CHECK-LABEL: @fdiv_nan_op0_fast( 172; CHECK-NEXT: ret float 0x7FF8000000000000 173; 174 %r = fdiv fast float 0x7FF8000000000000, %x 175 ret float %r 176} 177 178define float @fdiv_nan_op1_nnan(float %x) { 179; CHECK-LABEL: @fdiv_nan_op1_nnan( 180; CHECK-NEXT: ret float 0x7FF8000000000000 181; 182 %r = fdiv nnan float %x, 0x7FF8000000000000 183 ret float %r 184} 185 186define float @frem_nan_op0_nnan(float %x) { 187; CHECK-LABEL: @frem_nan_op0_nnan( 188; CHECK-NEXT: ret float 0x7FF8000000000000 189; 190 %r = frem nnan float 0x7FF8000000000000, %x 191 ret float %r 192} 193 194define float @frem_nan_op1_fast(float %x) { 195; CHECK-LABEL: @frem_nan_op1_fast( 196; CHECK-NEXT: ret float 0x7FF8000000000000 197; 198 %r = frem fast float %x, 0x7FF8000000000000 199 ret float %r 200} 201 202