1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -instsimplify -S < %s | FileCheck %s 3 4declare float @llvm.minnum.f32(float, float) 5declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) 6 7declare float @llvm.maxnum.f32(float, float) 8declare <4 x float> @llvm.maxnum.v4f32(<4 x float>, <4 x float>) 9 10declare float @llvm.minimum.f32(float, float) 11declare <4 x float> @llvm.minimum.v4f32(<4 x float>, <4 x float>) 12 13declare float @llvm.maximum.f32(float, float) 14declare <4 x float> @llvm.maximum.v4f32(<4 x float>, <4 x float>) 15 16declare i8 @llvm.smax.i8(i8, i8) 17declare <5 x i8> @llvm.smax.v5i8(<5 x i8>, <5 x i8>) 18 19declare i8 @llvm.smin.i8(i8, i8) 20declare <5 x i8> @llvm.smin.v5i8(<5 x i8>, <5 x i8>) 21 22declare i8 @llvm.umax.i8(i8, i8) 23declare <5 x i8> @llvm.umax.v5i8(<5 x i8>, <5 x i8>) 24 25declare i8 @llvm.umin.i8(i8, i8) 26declare <5 x i8> @llvm.umin.v5i8(<5 x i8>, <5 x i8>) 27 28define float @minnum_float() { 29; CHECK-LABEL: @minnum_float( 30; CHECK-NEXT: ret float 5.000000e+00 31; 32 %1 = call float @llvm.minnum.f32(float 5.0, float 42.0) 33 ret float %1 34} 35 36; Check that minnum constant folds to propagate non-NaN or smaller argument 37 38define <4 x float> @minnum_float_vec() { 39; CHECK-LABEL: @minnum_float_vec( 40; CHECK-NEXT: ret <4 x float> <float 0x7FF8000000000000, float 5.000000e+00, float 4.200000e+01, float 5.000000e+00> 41; 42 %1 = call <4 x float> @llvm.minnum.v4f32(<4 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float 42., float 42.>, <4 x float> <float 0x7FF8000000000000, float 5., float 0x7FF8000000000000, float 5.>) 43 ret <4 x float> %1 44} 45 46; Check that minnum constant folds to propagate one of its argument zeros 47 48define <4 x float> @minnum_float_zeros_vec() { 49; CHECK-LABEL: @minnum_float_zeros_vec( 50; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float -0.000000e+00, float 0.000000e+00, float -0.000000e+00> 51; 52 %1 = call <4 x float> @llvm.minnum.v4f32(<4 x float> <float 0.0, float -0.0, float 0.0, float -0.0>, <4 x float> <float 0.0, float 0.0, float -0.0, float -0.0>) 53 ret <4 x float> %1 54} 55 56define float @maxnum_float() { 57; CHECK-LABEL: @maxnum_float( 58; CHECK-NEXT: ret float 4.200000e+01 59; 60 %1 = call float @llvm.maxnum.f32(float 5.0, float 42.0) 61 ret float %1 62} 63 64; Check that maxnum constant folds to propagate non-NaN or greater argument 65 66define <4 x float> @maxnum_float_vec() { 67; CHECK-LABEL: @maxnum_float_vec( 68; CHECK-NEXT: ret <4 x float> <float 0x7FF8000000000000, float 5.000000e+00, float 4.200000e+01, float 4.200000e+01> 69; 70 %1 = call <4 x float> @llvm.maxnum.v4f32(<4 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float 42., float 42.>, <4 x float> <float 0x7FF8000000000000, float 5., float 0x7FF8000000000000, float 5.>) 71 ret <4 x float> %1 72} 73 74; Check that maxnum constant folds to propagate one of its argument zeros 75 76define <4 x float> @maxnum_float_zeros_vec() { 77; CHECK-LABEL: @maxnum_float_zeros_vec( 78; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float -0.000000e+00, float 0.000000e+00, float -0.000000e+00> 79; 80 %1 = call <4 x float> @llvm.maxnum.v4f32(<4 x float> <float 0.0, float -0.0, float 0.0, float -0.0>, <4 x float> <float 0.0, float 0.0, float -0.0, float -0.0>) 81 ret <4 x float> %1 82} 83 84define float @minimum_float() { 85; CHECK-LABEL: @minimum_float( 86; CHECK-NEXT: ret float 5.000000e+00 87; 88 %1 = call float @llvm.minimum.f32(float 5.0, float 42.0) 89 ret float %1 90} 91 92; Check that minimum propagates its NaN or smaller argument 93 94define <4 x float> @minimum_float_vec() { 95; CHECK-LABEL: @minimum_float_vec( 96; CHECK-NEXT: ret <4 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float 0x7FF8000000000000, float 5.000000e+00> 97; 98 %1 = call <4 x float> @llvm.minimum.v4f32(<4 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float 42., float 42.>, <4 x float> <float 0x7FF8000000000000, float 5., float 0x7FF8000000000000, float 5.>) 99 ret <4 x float> %1 100} 101 102; Check that minimum treats -0.0 as smaller than 0.0 while constant folding 103 104define <4 x float> @minimum_float_zeros_vec() { 105; CHECK-LABEL: @minimum_float_zeros_vec( 106; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float -0.000000e+00, float -0.000000e+00, float -0.000000e+00> 107; 108 %1 = call <4 x float> @llvm.minimum.v4f32(<4 x float> <float 0.0, float -0.0, float 0.0, float -0.0>, <4 x float> <float 0.0, float 0.0, float -0.0, float -0.0>) 109 ret <4 x float> %1 110} 111 112define float @maximum_float() { 113; CHECK-LABEL: @maximum_float( 114; CHECK-NEXT: ret float 4.200000e+01 115; 116 %1 = call float @llvm.maximum.f32(float 5.0, float 42.0) 117 ret float %1 118} 119 120; Check that maximum propagates its NaN or greater argument 121 122define <4 x float> @maximum_float_vec() { 123; CHECK-LABEL: @maximum_float_vec( 124; CHECK-NEXT: ret <4 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float 0x7FF8000000000000, float 4.200000e+01> 125; 126 %1 = call <4 x float> @llvm.maximum.v4f32(<4 x float> <float 0x7FF8000000000000, float 0x7FF8000000000000, float 42., float 42.>, <4 x float> <float 0x7FF8000000000000, float 5., float 0x7FF8000000000000, float 5.>) 127 ret <4 x float> %1 128} 129 130; Check that maximum treats -0.0 as smaller than 0.0 while constant folding 131 132define <4 x float> @maximum_float_zeros_vec() { 133; CHECK-LABEL: @maximum_float_zeros_vec( 134; CHECK-NEXT: ret <4 x float> <float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float -0.000000e+00> 135; 136 %1 = call <4 x float> @llvm.maximum.v4f32(<4 x float> <float 0.0, float -0.0, float 0.0, float -0.0>, <4 x float> <float 0.0, float 0.0, float -0.0, float -0.0>) 137 ret <4 x float> %1 138} 139 140define i8 @smax() { 141; CHECK-LABEL: @smax( 142; CHECK-NEXT: ret i8 -127 143; 144 %r = call i8 @llvm.smax.i8(i8 128, i8 129) 145 ret i8 %r 146} 147 148define <5 x i8> @smax_vec() { 149; CHECK-LABEL: @smax_vec( 150; CHECK-NEXT: ret <5 x i8> <i8 undef, i8 127, i8 127, i8 42, i8 127> 151; 152 %r = call <5 x i8> @llvm.smax.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 127>) 153 ret <5 x i8> %r 154} 155 156define i8 @smin() { 157; CHECK-LABEL: @smin( 158; CHECK-NEXT: ret i8 -128 159; 160 %r = call i8 @llvm.smin.i8(i8 128, i8 127) 161 ret i8 %r 162} 163 164define <5 x i8> @smin_vec() { 165; CHECK-LABEL: @smin_vec( 166; CHECK-NEXT: ret <5 x i8> <i8 undef, i8 -128, i8 -128, i8 42, i8 -127> 167; 168 %r = call <5 x i8> @llvm.smin.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 129>) 169 ret <5 x i8> %r 170} 171 172define i8 @umax() { 173; CHECK-LABEL: @umax( 174; CHECK-NEXT: ret i8 -128 175; 176 %r = call i8 @llvm.umax.i8(i8 128, i8 127) 177 ret i8 %r 178} 179 180define <5 x i8> @umax_vec() { 181; CHECK-LABEL: @umax_vec( 182; CHECK-NEXT: ret <5 x i8> <i8 undef, i8 -1, i8 -1, i8 42, i8 -128> 183; 184 %r = call <5 x i8> @llvm.umax.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 128>) 185 ret <5 x i8> %r 186} 187 188define i8 @umin() { 189; CHECK-LABEL: @umin( 190; CHECK-NEXT: ret i8 127 191; 192 %r = call i8 @llvm.umin.i8(i8 128, i8 127) 193 ret i8 %r 194} 195 196define <5 x i8> @umin_vec() { 197; CHECK-LABEL: @umin_vec( 198; CHECK-NEXT: ret <5 x i8> <i8 undef, i8 0, i8 0, i8 42, i8 42> 199; 200 %r = call <5 x i8> @llvm.umin.v5i8(<5 x i8> <i8 undef, i8 undef, i8 1, i8 42, i8 42>, <5 x i8> <i8 undef, i8 1, i8 undef, i8 42, i8 128>) 201 ret <5 x i8> %r 202} 203