brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.3 KiB · 6baac78 Raw
65 lines · plain
1; This test shows how value attributes are being passed during different translation steps.2; See also test/CodeGen/SPIRV/optimizations/add-check-overflow.ll.3 4; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -print-after=prepare-functions 2>&1 | FileCheck %s  --check-prefix=CHECK-PREPARE5; Intrinsics with aggregate return type are not substituted/removed.6; CHECK-PREPARE: @llvm.uadd.with.overflow.i327 8; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -print-after=emit-intrinsics 2>&1 | FileCheck %s  --check-prefix=CHECK-IR9; Aggregate data are wrapped into @llvm.fake.use(),10; and their attributes are packed into a metadata for @llvm.spv.value.md().11; CHECK-IR: %[[R1:.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i3212; CHECK-IR: call void @llvm.spv.value.md(metadata !1)13; CHECK-IR: call void (...) @llvm.fake.use({ i32, i1 } %[[R1]])14; CHECK-IR: %math = extractvalue { i32, i1 } %[[R1]], 015; CHECK-IR: %ov = extractvalue { i32, i1 } %[[R1]], 116; Type/Name attributes of the value.17; CHECK-IR: !1 = !{{[{]}}!2, !""{{[}]}}18; Origin data type of the value.19; CHECK-IR: !2 = !{{[{]}}{{[{]}} i32, i1 {{[}]}} poison{{[}]}}20 21; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -print-after=irtranslator 2>&1 | FileCheck %s  --check-prefix=CHECK-GMIR22; Required info succeeded to get through IRTranslator.23; CHECK-GMIR: %[[phires:.*]]:_(s32) = G_PHI24; CHECK-GMIR: %[[math:.*]]:id(s32), %[[ov:.*]]:_(s1) = G_UADDO %[[phires]]:_, %[[#]]:_25; CHECK-GMIR: G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.spv.value.md), !126; CHECK-GMIR: FAKE_USE %[[math]]:id(s32), %[[ov]]:_(s1)27 28; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -print-after=spirv-prelegalizer 2>&1 | FileCheck %s  --check-prefix=CHECK-PRE29; Internal service instructions are consumed.30; CHECK-PRE: G_UADDO31; CHECK-PRE-NO: llvm.spv.value.md32; CHECK-PRE-NO: FAKE_USE33 34; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -print-after=instruction-select 2>&1 | FileCheck %s  --check-prefix=CHECK-ISEL35; Names and types are restored and correctly encoded. Correct instruction selection is completed.36; CHECK-ISEL-DAG: %[[int32:.*]]:type = OpTypeInt 32, 037; CHECK-ISEL-DAG: %[[struct:.*]]:type = OpTypeStruct %[[int32]]:type, %[[int32]]:type38; CHECK-ISEL-DAG: %[[bool:.*]]:type = OpTypeBool39; CHECK-ISEL-DAG: %[[zero32:.*]]:iid = OpConstantNull %[[int32]]:type40; CHECK-ISEL-DAG: %[[res:.*]]:iid = OpIAddCarryS %[[struct]]:type41; CHECK-ISEL-DAG: %[[math:.*]]:id = OpCompositeExtract %[[int32]]:type, %[[res]]:iid, 042; CHECK-ISEL-DAG: %[[ov32:.*]]:iid = OpCompositeExtract %[[int32]]:type, %[[res]]:iid, 143; CHECK-ISEL-DAG: %[[ov:.*]]:iid = OpINotEqual %[[bool]]:type, %[[ov32]]:iid, %[[zero32:.*]]:iid44; CHECK-ISEL-DAG: OpName %[[math]]:id, 1752457581, 045; CHECK-ISEL-DAG: OpName %[[ov]]:iid, 3031946 47define spir_func i32 @foo(i32 %a, ptr addrspace(4) %p) {48entry:49  br label %l150 51l1:                                               ; preds = %body, %entry52  %e = phi i32 [ %a, %entry ], [ %math, %body ]53  %0 = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %e, i32 1)54  %math = extractvalue { i32, i1 } %0, 055  %ov = extractvalue { i32, i1 } %0, 156  br i1 %ov, label %exit, label %body57 58body:                                             ; preds = %l159  store i8 42, ptr addrspace(4) %p, align 160  br label %l161 62exit:                                             ; preds = %l163  ret i32 %math64}65