brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.1 KiB · 9d35fb3 Raw
194 lines · plain
1; RUN: llc -mtriple=spirv-unknown-vulkan-compute -O0 %s -o - | FileCheck %s2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-vulkan-compute %s -o - -filetype=obj | spirv-val %}3 4;5; int fn() { return true; }6;7; int process() {8;   // Use in control flow9;   int a = 0;10;   int b = 0;11;   int val = 0;12;   if (a && b) val++;13;14;   // Operand with side effects15;   if (fn() && fn()) val++;16;17;   if (a && fn())18;     val++;19;20;   if (fn() && b)21;     val++;22;   return val;23; }24;25; [numthreads(1, 1, 1)]26; void main() {27;   process();28; }29 30; CHECK:  %[[#func_9:]] = OpFunction %[[#uint:]] DontInline %[[#]]31; CHECK:    %[[#bb43:]] = OpLabel32; CHECK:                  OpReturnValue %[[#]]33; CHECK:                  OpFunctionEnd34; CHECK: %[[#func_10:]] = OpFunction %[[#uint:]] DontInline %[[#]]35; CHECK:    %[[#bb44:]] = OpLabel36; CHECK:                  OpSelectionMerge %[[#bb45:]] None37; CHECK:                  OpBranchConditional %[[#]] %[[#bb46:]] %[[#bb45:]]38; CHECK:    %[[#bb46:]] = OpLabel39; CHECK:                  OpBranchConditional %[[#]] %[[#bb47:]] %[[#bb45:]]40; CHECK:    %[[#bb47:]] = OpLabel41; CHECK:                  OpBranch %[[#bb45:]]42; CHECK:    %[[#bb45:]] = OpLabel43; CHECK:                  OpSelectionMerge %[[#bb48:]] None44; CHECK:                  OpBranchConditional %[[#]] %[[#bb49:]] %[[#bb48:]]45; CHECK:    %[[#bb49:]] = OpLabel46; CHECK:                  OpBranchConditional %[[#]] %[[#bb50:]] %[[#bb48:]]47; CHECK:    %[[#bb50:]] = OpLabel48; CHECK:                  OpBranch %[[#bb48:]]49; CHECK:    %[[#bb48:]] = OpLabel50; CHECK:                  OpSelectionMerge %[[#bb51:]] None51; CHECK:                  OpBranchConditional %[[#]] %[[#bb52:]] %[[#bb51:]]52; CHECK:    %[[#bb52:]] = OpLabel53; CHECK:                  OpBranchConditional %[[#]] %[[#bb53:]] %[[#bb51:]]54; CHECK:    %[[#bb53:]] = OpLabel55; CHECK:                  OpBranch %[[#bb51:]]56; CHECK:    %[[#bb51:]] = OpLabel57; CHECK:                  OpSelectionMerge %[[#bb54:]] None58; CHECK:                  OpBranchConditional %[[#]] %[[#bb55:]] %[[#bb54:]]59; CHECK:    %[[#bb55:]] = OpLabel60; CHECK:                  OpBranchConditional %[[#]] %[[#bb56:]] %[[#bb54:]]61; CHECK:    %[[#bb56:]] = OpLabel62; CHECK:                  OpBranch %[[#bb54:]]63; CHECK:    %[[#bb54:]] = OpLabel64; CHECK:                  OpReturnValue %[[#]]65; CHECK:                  OpFunctionEnd66; CHECK: %[[#func_39:]] = OpFunction %[[#void:]] DontInline %[[#]]67; CHECK:    %[[#bb57:]] = OpLabel68; CHECK:                  OpReturn69; CHECK:                  OpFunctionEnd70; CHECK: %[[#func_41:]] = OpFunction %[[#void:]] None %[[#]]71; CHECK:    %[[#bb58:]] = OpLabel72; CHECK:                  OpReturn73; CHECK:                  OpFunctionEnd74 75target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"76target triple = "spirv-unknown-vulkan1.3-compute"77 78; Function Attrs: convergent noinline norecurse nounwind optnone79define spir_func noundef i32 @_Z2fnv() #0 {80entry:81  %0 = call token @llvm.experimental.convergence.entry()82  ret i32 183}84 85; Function Attrs: convergent nocallback nofree nosync nounwind willreturn memory(none)86declare token @llvm.experimental.convergence.entry() #187 88; Function Attrs: convergent noinline norecurse nounwind optnone89define spir_func noundef i32 @_Z7processv() #0 {90entry:91  %0 = call token @llvm.experimental.convergence.entry()92  %a = alloca i32, align 493  %b = alloca i32, align 494  %val = alloca i32, align 495  store i32 0, ptr %a, align 496  store i32 0, ptr %b, align 497  store i32 0, ptr %val, align 498  %1 = load i32, ptr %a, align 499  %tobool = icmp ne i32 %1, 0100  br i1 %tobool, label %land.lhs.true, label %if.end101 102land.lhs.true:                                    ; preds = %entry103  %2 = load i32, ptr %b, align 4104  %tobool1 = icmp ne i32 %2, 0105  br i1 %tobool1, label %if.then, label %if.end106 107if.then:                                          ; preds = %land.lhs.true108  %3 = load i32, ptr %val, align 4109  %inc = add nsw i32 %3, 1110  store i32 %inc, ptr %val, align 4111  br label %if.end112 113if.end:                                           ; preds = %if.then, %land.lhs.true, %entry114  %call2 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]115  %tobool3 = icmp ne i32 %call2, 0116  br i1 %tobool3, label %land.lhs.true4, label %if.end9117 118land.lhs.true4:                                   ; preds = %if.end119  %call5 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]120  %tobool6 = icmp ne i32 %call5, 0121  br i1 %tobool6, label %if.then7, label %if.end9122 123if.then7:                                         ; preds = %land.lhs.true4124  %4 = load i32, ptr %val, align 4125  %inc8 = add nsw i32 %4, 1126  store i32 %inc8, ptr %val, align 4127  br label %if.end9128 129if.end9:                                          ; preds = %if.then7, %land.lhs.true4, %if.end130  %5 = load i32, ptr %a, align 4131  %tobool10 = icmp ne i32 %5, 0132  br i1 %tobool10, label %land.lhs.true11, label %if.end16133 134land.lhs.true11:                                  ; preds = %if.end9135  %call12 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]136  %tobool13 = icmp ne i32 %call12, 0137  br i1 %tobool13, label %if.then14, label %if.end16138 139if.then14:                                        ; preds = %land.lhs.true11140  %6 = load i32, ptr %val, align 4141  %inc15 = add nsw i32 %6, 1142  store i32 %inc15, ptr %val, align 4143  br label %if.end16144 145if.end16:                                         ; preds = %if.then14, %land.lhs.true11, %if.end9146  %call17 = call spir_func noundef i32 @_Z2fnv() #3 [ "convergencectrl"(token %0) ]147  %tobool18 = icmp ne i32 %call17, 0148  br i1 %tobool18, label %land.lhs.true19, label %if.end23149 150land.lhs.true19:                                  ; preds = %if.end16151  %7 = load i32, ptr %b, align 4152  %tobool20 = icmp ne i32 %7, 0153  br i1 %tobool20, label %if.then21, label %if.end23154 155if.then21:                                        ; preds = %land.lhs.true19156  %8 = load i32, ptr %val, align 4157  %inc22 = add nsw i32 %8, 1158  store i32 %inc22, ptr %val, align 4159  br label %if.end23160 161if.end23:                                         ; preds = %if.then21, %land.lhs.true19, %if.end16162  %9 = load i32, ptr %val, align 4163  ret i32 %9164}165 166; Function Attrs: convergent noinline norecurse nounwind optnone167define internal spir_func void @main() #0 {168entry:169  %0 = call token @llvm.experimental.convergence.entry()170  %call1 = call spir_func noundef i32 @_Z7processv() #3 [ "convergencectrl"(token %0) ]171  ret void172}173 174; Function Attrs: convergent norecurse175define void @main.1() #2 {176entry:177  call void @main()178  ret void179}180 181attributes #0 = { convergent noinline norecurse nounwind optnone "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }182attributes #1 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }183attributes #2 = { convergent norecurse "frame-pointer"="all" "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }184attributes #3 = { convergent }185 186!llvm.module.flags = !{!0, !1, !2}187 188 189!0 = !{i32 1, !"wchar_size", i32 4}190!1 = !{i32 4, !"dx.disable_optimizations", i32 1}191!2 = !{i32 7, !"frame-pointer", i32 2}192 193 194