1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -ast-dump %s | FileCheck %s
// CHECK: FunctionDecl {{.*}} used branch 'int (int)'
// CHECK: AttributedStmt
// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} branch
export int branch(int X){
int resp;
[branch] if (X > 0) {
resp = -X;
} else {
resp = X * 2;
}
return resp;
}
// CHECK: FunctionDecl {{.*}} used flatten 'int (int)'
// CHECK: AttributedStmt
// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} flatten
export int flatten(int X){
int resp;
[flatten] if (X > 0) {
resp = -X;
} else {
resp = X * 2;
}
return resp;
}
// CHECK: FunctionDecl {{.*}} used no_attr 'int (int)'
// CHECK-NOT: AttributedStmt
// CHECK-NOT: HLSLControlFlowHintAttr
export int no_attr(int X){
int resp;
if (X > 0) {
resp = -X;
} else {
resp = X * 2;
}
return resp;
}
// CHECK: FunctionDecl {{.*}} used flatten_switch 'int (int)'
// CHECK: AttributedStmt
// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} flatten
export int flatten_switch(int X){
int resp;
[flatten]
switch (X) {
case 0:
resp = -X;
break;
case 1:
resp = X+X;
break;
case 2:
resp = X * X; break;
}
return resp;
}
// CHECK: FunctionDecl {{.*}} used branch_switch 'int (int)'
// CHECK: AttributedStmt
// CHECK-NEXT: HLSLControlFlowHintAttr {{.*}} branch
export int branch_switch(int X){
int resp;
[branch]
switch (X) {
case 0:
resp = -X;
break;
case 1:
resp = X+X;
break;
case 2:
resp = X * X; break;
}
return resp;
}
// CHECK: FunctionDecl {{.*}} used no_attr_switch 'int (int)'
// CHECK-NOT: AttributedStmt
// CHECK-NOT: HLSLControlFlowHintAttr
export int no_attr_switch(int X){
int resp;
switch (X) {
case 0:
resp = -X;
break;
case 1:
resp = X+X;
break;
case 2:
resp = X * X; break;
}
return resp;
}
|