Skip to content

Commit 558f200

Browse files
committed
Add more test cases
1 parent 1964539 commit 558f200

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

clang/test/CIR/CodeGen/vector.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,3 +1085,43 @@ void foo20() {
10851085

10861086
// OGCG: %[[VEC_COND:.*]] = icmp ne <4 x i32> {{.*}}, zeroinitializer
10871087
// OGCG: %[[RES:.*]] = select <4 x i1> %[[VEC_COND]], <4 x i32> {{.*}}, <4 x i32> {{.*}}
1088+
1089+
void foo21() {
1090+
vi4 a;
1091+
vi4 b;
1092+
vi4 r = (a > b) ? (a - b) : (b - a);
1093+
}
1094+
1095+
// CIR: %[[VEC_COND:.*]] = cir.vec.cmp(gt, {{.*}}, {{.*}}) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
1096+
// CIR: %[[LHS:.*]] = cir.binop(sub, {{.*}}, {{.*}}) : !cir.vector<4 x !s32i>
1097+
// CIR: %[[RHS:.*]] = cir.binop(sub, {{.*}}, {{.*}}) : !cir.vector<4 x !s32i>
1098+
// CIR: %[[RES:.*]] = cir.vec.ternary(%[[VEC_COND]], %[[LHS]], %[[RHS]]) : !cir.vector<4 x !s32i>, !cir.vector<4 x !s32i>
1099+
1100+
// LLVM: %[[CMP:.*]] = icmp sgt <4 x i32> {{.*}}, {{.*}}
1101+
// LLVM: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
1102+
// LLVM: %[[LHS:.*]] = sub <4 x i32> {{.*}}, {{.*}}
1103+
// LLVM: %[[RHS:.*]] = sub <4 x i32> {{.*}}, {{.*}}
1104+
// LLVM: %[[VEC_COND:.*]] = icmp ne <4 x i32> %[[SEXT]], zeroinitializer
1105+
// LLVM: %[[RES:.*]] = select <4 x i1> %[[VEC_COND]], <4 x i32> %[[LHS]], <4 x i32> %[[RHS]]
1106+
1107+
// OGCG: %[[CMP:.*]] = icmp sgt <4 x i32> {{.*}}, {{.*}}
1108+
// OGCG: %[[SEXT:.*]] = sext <4 x i1> %[[CMP]] to <4 x i32>
1109+
// OGCG: %[[LHS:.*]] = sub <4 x i32> {{.*}}, {{.*}}
1110+
// OGCG: %[[RHS:.*]] = sub <4 x i32> {{.*}}, {{.*}}
1111+
// OGCG: %[[VEC_COND:.*]] = icmp ne <4 x i32> %[[SEXT]], zeroinitializer
1112+
// OGCG: %[[RES:.*]] = select <4 x i1> %[[VEC_COND]], <4 x i32> %[[LHS]], <4 x i32> %[[RHS]]
1113+
1114+
void foo22() {
1115+
vf4 a;
1116+
vf4 b;
1117+
vi4 c;
1118+
vf4 r = c ? a : b;
1119+
}
1120+
1121+
// CIR: %[[RES:.*]] = cir.vec.ternary({{.*}}, {{.*}}, {{.*}}) : !cir.vector<4 x !s32i>, !cir.vector<4 x !cir.float>
1122+
1123+
// LLVM: %[[VEC_COND:.*]] = icmp ne <4 x i32> {{.*}}, zeroinitializer
1124+
// LLVM: %[[RES:.*]] = select <4 x i1> %[[VEC_COND]], <4 x float> {{.*}}, <4 x float> {{.*}}
1125+
1126+
// OGCG: %[[VEC_COND:.*]] = icmp ne <4 x i32> {{.*}}, zeroinitializer
1127+
// OGCG: %[[RES:.*]] = select <4 x i1> %[[VEC_COND]], <4 x float> {{.*}}, <4 x float> {{.*}}

0 commit comments

Comments
 (0)