122 lines · plain
1; RUN: opt -S -scalarizer -dxil-op-lower -mtriple=dxil-pc-shadermodel6.3-library %s | FileCheck %s2 3; Make sure dxil operation function calls for firstbithigh are generated for all integer types.4 5define noundef i32 @test_firstbithigh_ushort(i16 noundef %a) {6entry:7; CHECK: call i32 @dx.op.unaryBits.i16(i32 33, i16 %{{.*}})8 %elt.firstbithigh = call i32 @llvm.dx.firstbituhigh.i16(i16 %a)9 ret i32 %elt.firstbithigh10}11 12define noundef i32 @test_firstbithigh_short(i16 noundef %a) {13entry:14; CHECK: call i32 @dx.op.unaryBits.i16(i32 34, i16 %{{.*}})15 %elt.firstbithigh = call i32 @llvm.dx.firstbitshigh.i16(i16 %a)16 ret i32 %elt.firstbithigh17}18 19define noundef i32 @test_firstbithigh_uint(i32 noundef %a) {20entry:21; CHECK: call i32 @dx.op.unaryBits.i32(i32 33, i32 %{{.*}})22 %elt.firstbithigh = call i32 @llvm.dx.firstbituhigh.i32(i32 %a)23 ret i32 %elt.firstbithigh24}25 26define noundef i32 @test_firstbithigh_int(i32 noundef %a) {27entry:28; CHECK: call i32 @dx.op.unaryBits.i32(i32 34, i32 %{{.*}})29 %elt.firstbithigh = call i32 @llvm.dx.firstbitshigh.i32(i32 %a)30 ret i32 %elt.firstbithigh31}32 33define noundef i32 @test_firstbithigh_ulong(i64 noundef %a) {34entry:35; CHECK: call i32 @dx.op.unaryBits.i64(i32 33, i64 %{{.*}})36 %elt.firstbithigh = call i32 @llvm.dx.firstbituhigh.i64(i64 %a)37 ret i32 %elt.firstbithigh38}39 40define noundef i32 @test_firstbithigh_long(i64 noundef %a) {41entry:42; CHECK: call i32 @dx.op.unaryBits.i64(i32 34, i64 %{{.*}})43 %elt.firstbithigh = call i32 @llvm.dx.firstbitshigh.i64(i64 %a)44 ret i32 %elt.firstbithigh45}46 47define noundef <4 x i32> @test_firstbituhigh_vec4_i32(<4 x i32> noundef %a) {48entry:49 ; CHECK: [[ee0:%.*]] = extractelement <4 x i32> %a, i64 050 ; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee0]])51 ; CHECK: [[ee1:%.*]] = extractelement <4 x i32> %a, i64 152 ; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee1]])53 ; CHECK: [[ee2:%.*]] = extractelement <4 x i32> %a, i64 254 ; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee2]])55 ; CHECK: [[ee3:%.*]] = extractelement <4 x i32> %a, i64 356 ; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 33, i32 [[ee3]])57 ; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 058 ; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 159 ; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 260 ; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 361 ; CHECK: ret <4 x i32> [[rt3]]62 %2 = call <4 x i32> @llvm.dx.firstbituhigh.v4i32(<4 x i32> %a)63 ret <4 x i32> %264}65 66define noundef <4 x i32> @test_firstbitshigh_vec4_i32(<4 x i32> noundef %a) {67entry:68 ; CHECK: [[ee0:%.*]] = extractelement <4 x i32> %a, i64 069 ; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee0]])70 ; CHECK: [[ee1:%.*]] = extractelement <4 x i32> %a, i64 171 ; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee1]])72 ; CHECK: [[ee2:%.*]] = extractelement <4 x i32> %a, i64 273 ; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee2]])74 ; CHECK: [[ee3:%.*]] = extractelement <4 x i32> %a, i64 375 ; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i32(i32 34, i32 [[ee3]])76 ; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 077 ; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 178 ; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 279 ; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 380 ; CHECK: ret <4 x i32> [[rt3]]81 %2 = call <4 x i32> @llvm.dx.firstbitshigh.v4i32(<4 x i32> %a)82 ret <4 x i32> %283}84 85define noundef <4 x i32> @test_firstbituhigh_vec4_i16(<4 x i16> noundef %a) {86entry:87 ; CHECK: [[ee0:%.*]] = extractelement <4 x i16> %a, i64 088 ; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee0]])89 ; CHECK: [[ee1:%.*]] = extractelement <4 x i16> %a, i64 190 ; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee1]])91 ; CHECK: [[ee2:%.*]] = extractelement <4 x i16> %a, i64 292 ; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee2]])93 ; CHECK: [[ee3:%.*]] = extractelement <4 x i16> %a, i64 394 ; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i16(i32 33, i16 [[ee3]])95 ; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 096 ; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 197 ; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 298 ; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 399 ; CHECK: ret <4 x i32> [[rt3]]100 %2 = call <4 x i32> @llvm.dx.firstbituhigh.v4i16(<4 x i16> %a)101 ret <4 x i32> %2102}103 104define noundef <4 x i32> @test_firstbitshigh_vec4_i16(<4 x i16> noundef %a) {105entry:106 ; CHECK: [[ee0:%.*]] = extractelement <4 x i16> %a, i64 0107 ; CHECK: [[ie0:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee0]])108 ; CHECK: [[ee1:%.*]] = extractelement <4 x i16> %a, i64 1109 ; CHECK: [[ie1:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee1]])110 ; CHECK: [[ee2:%.*]] = extractelement <4 x i16> %a, i64 2111 ; CHECK: [[ie2:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee2]])112 ; CHECK: [[ee3:%.*]] = extractelement <4 x i16> %a, i64 3113 ; CHECK: [[ie3:%.*]] = call i32 @dx.op.unaryBits.i16(i32 34, i16 [[ee3]])114 ; CHECK: [[rt0:%.*]] = insertelement <4 x i32> poison, i32 [[ie0]], i64 0115 ; CHECK: [[rt1:%.*]] = insertelement <4 x i32> [[rt0]], i32 [[ie1]], i64 1116 ; CHECK: [[rt2:%.*]] = insertelement <4 x i32> [[rt1]], i32 [[ie2]], i64 2117 ; CHECK: [[rt3:%.*]] = insertelement <4 x i32> [[rt2]], i32 [[ie3]], i64 3118 ; CHECK: ret <4 x i32> [[rt3]]119 %2 = call <4 x i32> @llvm.dx.firstbitshigh.v4i16(<4 x i16> %a)120 ret <4 x i32> %2121}122