brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 2db620d Raw
92 lines · plain
1; This test aims to check ability to support "Arithmetic with Overflow" intrinsics2; in the special case when those intrinsics are being generated by the CodeGenPrepare;3; pass during translations with optimization (note -disable-lsr, to inhibit4; strength reduction pre-empting with a more preferable match for this pattern5; in llc arguments).6 7; RUN: llc -O3 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s8; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}9 10; RUN: llc -O3 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s11; RUN: %if spirv-tools %{ llc -O3 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}12 13; RUN: llc -O3 -disable-lsr -mtriple=spirv32-unknown-unknown %s -o - | FileCheck --check-prefix=NOLSR %s14; RUN: %if spirv-tools %{ llc -O3 -disable-lsr -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}15 16; RUN: llc -O3 -disable-lsr -mtriple=spirv64-unknown-unknown %s -o - | FileCheck --check-prefix=NOLSR %s17; RUN: %if spirv-tools %{ llc -O3 -disable-lsr -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}18 19; CHECK-DAG: OpName %[[PhiRes:.*]] "lsr.iv"20; CHECK-DAG: OpName %[[IsOver:.*]] "fl"21; CHECK-DAG: OpName %[[Val:.*]] "lsr.iv.next"22; CHECK-DAG: %[[Int:.*]] = OpTypeInt 32 023; CHECK-DAG: %[[Char:.*]] = OpTypeInt 8 024; CHECK-DAG: %[[PtrChar:.*]] = OpTypePointer Generic %[[Char]]25; CHECK-DAG: %[[Bool:.*]] = OpTypeBool26; CHECK-DAG: %[[Const1:.*]] = OpConstant %[[Int]] 1{{$}}27; CHECK-DAG: %[[Zero:.*]] = OpConstantNull %[[Int]]28; CHECK-DAG: %[[Const42:.*]] = OpConstant %[[Char]] 42{{$}}29 30; CHECK: OpFunction31; CHECK: %[[A:.*]] = OpFunctionParameter %[[Int]]32; CHECK: %[[Ptr:.*]] = OpFunctionParameter %[[PtrChar]]33; CHECK: %[[APlusOne:.*]] = OpIAdd %[[Int]] %[[A]] %[[Const1]]34;	CHECK: OpBranch %[[#]]35;	CHECK: [[#]] = OpLabel36;	CHECK: %[[PhiRes]] = OpPhi %[[Int]] %[[Val]] %[[#]] %[[APlusOne]] %[[#]]37;	CHECK: %[[IsOver]] = OpIEqual %[[Bool]] %[[#]] %[[#]]38;	CHECK: OpBranchConditional %[[IsOver]] %[[#]] %[[#]]39;	CHECK: [[#]] = OpLabel40;	CHECK: OpStore %[[Ptr]] %[[Const42]] Aligned 141;	CHECK: [[Val]] = OpIAdd %[[Int]] %[[PhiRes]] %[[Const1]]42; CHECK: OpBranch %[[#]]43;	CHECK: [[#]] = OpLabel44;	OpReturnValue %[[PhiRes]]45 46; NOLSR-DAG: OpName %[[Val:.*]] "math"47; NOLSR-DAG: OpName %[[IsOver:.*]] "ov"48; NOLSR-DAG: %[[Int:.*]] = OpTypeInt 32 049; NOLSR-DAG: %[[Char:.*]] = OpTypeInt 8 050; NOLSR-DAG: %[[PtrChar:.*]] = OpTypePointer Generic %[[Char]]51; NOLSR-DAG: %[[Bool:.*]] = OpTypeBool52; NOLSR-DAG: %[[Struct:.*]] = OpTypeStruct %[[Int]] %[[Int]]53; NOLSR-DAG: %[[Const1:.*]] = OpConstant %[[Int]] 154; NOLSR-DAG: %[[Const42:.*]] = OpConstant %[[Char]] 4255; NOLSR-DAG: %[[Zero:.*]] = OpConstantNull %[[Int]]56 57; NOLSR: OpFunction58; NOLSR: %[[A:.*]] = OpFunctionParameter %[[Int]]59; NOLSR: %[[Ptr:.*]] = OpFunctionParameter %[[PtrChar]]60; NOLSR: %[[#]] = OpLabel61; NOLSR: OpBranch %[[#]]62; NOLSR: %[[#]] = OpLabel63; NOLSR: %[[PhiRes:.*]] = OpPhi %[[Int]] %[[A]] %[[#]] %[[Val]] %[[#]]64; NOLSR: %[[AggRes:.*]] = OpIAddCarry %[[Struct]] %[[PhiRes]] %[[Const1]]65; NOLSR: %[[Val]] = OpCompositeExtract %[[Int]] %[[AggRes]] 066; NOLSR: %[[Over:.*]] = OpCompositeExtract %[[Int]] %[[AggRes]] 167; NOLSR: %[[IsOver]] = OpINotEqual %[[Bool:.*]] %[[Over]] %[[Zero]]68; NOLSR: OpBranchConditional %[[IsOver]] %[[#]] %[[#]]69; NOLSR: OpStore %[[Ptr]] %[[Const42]] Aligned 170; NOLSR: OpBranch %[[#]]71; NOLSR: %[[#]] = OpLabel72; NOLSR: OpReturnValue %[[Val]]73; NOLSR: OpFunctionEnd74 75define spir_func i32 @foo(i32 %a, ptr addrspace(4) %p) {76entry:77  br label %l178 79body:80  store i8 42, ptr addrspace(4) %p81  br label %l182 83l1:84  %e = phi i32 [ %a, %entry ], [ %i, %body ]85  %i = add nsw i32 %e, 186  %fl = icmp eq i32 %i, 087  br i1 %fl, label %exit, label %body88 89exit:90  ret i32 %i91}92