brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.1 KiB · 9524f02 Raw
124 lines · plain
1// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s2 3// array splat4// CHECK-LABEL: define void {{.*}}call45// CHECK: [[B:%.*]] = alloca [2 x i32], align 46// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[B]], ptr align 4 {{.*}}, i32 8, i1 false)7// CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds [2 x i32], ptr [[B]], i32 0, i32 08// CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds [2 x i32], ptr [[B]], i32 0, i32 19// CHECK-NEXT: store i32 3, ptr [[G1]], align 410// CHECK-NEXT: store i32 3, ptr [[G2]], align 411export void call4() {12  int B[2] = {1,2};13  B = (int[2])3;14}15 16// splat from vector of length 117// CHECK-LABEL: define void {{.*}}call818// CHECK: [[A:%.*]] = alloca <1 x i32>, align 419// CHECK-NEXT: [[B:%.*]] = alloca [2 x i32], align 420// CHECK-NEXT: store <1 x i32> splat (i32 1), ptr [[A]], align 421// CHECK-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 4 [[B]], ptr align 4 {{.*}}, i32 8, i1 false)22// CHECK-NEXT: [[L:%.*]] = load <1 x i32>, ptr [[A]], align 423// CHECK-NEXT: [[VL:%.*]] = extractelement <1 x i32> [[L]], i32 024// CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds [2 x i32], ptr [[B]], i32 0, i32 025// CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds [2 x i32], ptr [[B]], i32 0, i32 126// CHECK-NEXT: store i32 [[VL]], ptr [[G1]], align 427// CHECK-NEXT: store i32 [[VL]], ptr [[G2]], align 428export void call8() {29  int1 A = {1};30  int B[2] = {1,2};31  B = (int[2])A;32}33 34// vector splat from vector of length 135// CHECK-LABEL: define void {{.*}}call136// CHECK: [[B:%.*]] = alloca <1 x float>, align 437// CHECK-NEXT: [[A:%.*]] = alloca <4 x i32>, align 1638// CHECK-NEXT: store <1 x float> splat (float 1.000000e+00), ptr [[B]], align 439// CHECK-NEXT: [[L:%.*]] = load <1 x float>, ptr [[B]], align 440// CHECK-NEXT: [[VL:%.*]] = extractelement <1 x float> [[L]], i32 041// CHECK-NEXT: [[C:%.*]] = fptosi float [[VL]] to i3242// CHECK-NEXT: [[SI:%.*]] = insertelement <4 x i32> poison, i32 [[C]], i64 043// CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[SI]], <4 x i32> poison, <4 x i32> zeroinitializer44// CHECK-NEXT: store <4 x i32> [[S]], ptr [[A]], align 1645export void call1() {46  float1 B = {1.0};47  int4 A = (int4)B;48}49 50struct S {51  int X;52  float Y;53};54 55// struct splats56// CHECK-LABEL: define void {{.*}}call357// CHECK: [[AA:%.*]] = alloca i32, align 458// CHECK: [[s:%.*]] = alloca %struct.S, align 159// CHECK-NEXT: store i32 %A, ptr [[AA]], align 460// CHECK-NEXT: [[L:%.*]] = load i32, ptr [[AA]], align 461// CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds %struct.S, ptr [[s]], i32 0, i32 062// CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds %struct.S, ptr [[s]], i32 0, i32 163// CHECK-NEXT: store i32 [[L]], ptr [[G1]], align 464// CHECK-NEXT: [[C:%.*]] = sitofp i32 [[L]] to float65// CHECK-NEXT: store float [[C]], ptr [[G2]], align 466export void call3(int A) {67  S s = (S)A;68}69 70// struct splat from vector of length 171// CHECK-LABEL: define void {{.*}}call572// CHECK: [[A:%.*]] = alloca <1 x i32>, align 473// CHECK-NEXT: [[s:%.*]] = alloca %struct.S, align 174// CHECK-NEXT: store <1 x i32> splat (i32 1), ptr [[A]], align 475// CHECK-NEXT: [[L:%.*]] = load <1 x i32>, ptr [[A]], align 476// CHECK-NEXT: [[VL:%.*]] = extractelement <1 x i32> [[L]], i32 077// CHECK-NEXT: [[G1:%.*]] = getelementptr inbounds %struct.S, ptr [[s]], i32 0, i32 078// CHECK-NEXT: [[G2:%.*]] = getelementptr inbounds %struct.S, ptr [[s]], i32 0, i32 179// CHECK-NEXT: store i32 [[VL]], ptr [[G1]], align 480// CHECK-NEXT: [[C:%.*]] = sitofp i32 [[VL]] to float81// CHECK-NEXT: store float [[C]], ptr [[G2]], align 482export void call5() {83  int1 A = {1};84  S s = (S)A;85}86 87struct BFields {88  double DF;89  int E: 15;90  int : 8;91  float F;92};93 94struct Derived : BFields {95  int G;96};97 98// derived struct with bitfields splat from scalar99// CHECK-LABEL: call6100// CHECK: [[AAddr:%.*]] = alloca i32, align 4101// CHECK-NEXT: [[D:%.*]] = alloca %struct.Derived, align 1102// CHECK-NEXT: store i32 %A, ptr [[AAddr]], align 4103// CHECK-NEXT: [[B:%.*]] = load i32, ptr [[AAddr]], align 4104// CHECK-NEXT: [[Gep:%.*]] = getelementptr inbounds %struct.Derived, ptr [[D]], i32 0, i32 0105// CHECK-NEXT: [[E:%.*]] = getelementptr inbounds nuw %struct.BFields, ptr [[Gep]], i32 0, i32 1106// CHECK-NEXT: [[Gep1:%.*]] = getelementptr inbounds %struct.Derived, ptr [[D]], i32 0, i32 0, i32 0107// CHECK-NEXT: [[Gep2:%.*]] = getelementptr inbounds %struct.Derived, ptr [[D]], i32 0, i32 0, i32 2108// CHECK-NEXT: [[Gep3:%.*]] = getelementptr inbounds %struct.Derived, ptr [[D]], i32 0, i32 1109// CHECK-NEXT: [[C:%.*]] = sitofp i32 [[B]] to double110// CHECK-NEXT: store double [[C]], ptr [[Gep1]], align 8111// CHECK-NEXT: [[H:%.*]] = trunc i32 [[B]] to i24112// CHECK-NEXT: [[BFL:%.*]] = load i24, ptr [[E]], align 1113// CHECK-NEXT: [[BFV:%.*]] = and i24 [[H]], 32767114// CHECK-NEXT: [[BFC:%.*]] = and i24 [[BFL]], -32768115// CHECK-NEXT: [[BFS:%.*]] = or i24 [[BFC]], [[BFV]]116// CHECK-NEXT: store i24 [[BFS]], ptr [[E]], align 1117// CHECK-NEXT: [[C4:%.*]] = sitofp i32 [[B]] to float118// CHECK-NEXT: store float [[C4]], ptr [[Gep2]], align 4119// CHECK-NEXT: store i32 [[B]], ptr [[Gep3]], align 4120// CHECK-NEXT: ret void121export void call6(int A) {122  Derived D = (Derived)A;123}124