Skip to content

Commit 94f820b

Browse files
committed
Add direct test for VecCreateFolder
1 parent 072d673 commit 94f820b

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,7 @@ LogicalResult cir::GetMemberOp::verify() {
15341534
//===----------------------------------------------------------------------===//
15351535

15361536
OpFoldResult cir::VecCreateOp::fold(FoldAdaptor adaptor) {
1537-
auto elements = getElements();
1538-
if (llvm::any_of(elements, [](mlir::Value attr) {
1537+
if (llvm::any_of(getElements(), [](mlir::Value attr) {
15391538
return !mlir::isa<cir::ConstantOp>(attr.getDefiningOp());
15401539
}))
15411540
return {};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: cir-opt %s -cir-canonicalize -o - | FileCheck %s
2+
3+
!s32i = !cir.int<s, 32>
4+
5+
module {
6+
cir.func @fold_create_vector_op_test() -> !cir.vector<4 x !s32i> {
7+
%2 = cir.const #cir.int<1> : !s32i
8+
%3 = cir.const #cir.int<2> : !s32i
9+
%4 = cir.const #cir.int<3> : !s32i
10+
%5 = cir.const #cir.int<4> : !s32i
11+
%vec = cir.vec.create(%2, %3, %4, %5 : !s32i, !s32i, !s32i, !s32i) : !cir.vector<4 x !s32i>
12+
cir.return %vec : !cir.vector<4 x !s32i>
13+
}
14+
15+
// CHECK: cir.func @fold_create_vector_op_test() -> !cir.vector<4 x !s32i> {
16+
// CHECK-NEXT: %[[VEC:.*]] = cir.const #cir.const_vector<[#cir.int<1> : !s32i, #cir.int<2> : !s32i,
17+
// CHECK-SAME: #cir.int<3> : !s32i, #cir.int<4> : !s32i]> : !cir.vector<4 x !s32i>
18+
// CHECK-NEXT: cir.return %[[VEC]] : !cir.vector<4 x !s32i>
19+
}

0 commit comments

Comments
 (0)