Skip to content

Commit b442dd0

Browse files
committed
Address code review comments
1 parent 11de7d3 commit b442dd0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1981,14 +1981,14 @@ def VecInsertOp : CIR_Op<"vec.insert", [Pure,
19811981
let summary = "Insert one element into a vector object";
19821982
let description = [{
19831983
The `cir.vec.insert` operation replaces the element of the given vector at
1984-
the given index with the given value. The new vector with the inserted
1984+
the given index with the given value. The new vector with the inserted
19851985
element is returned.
19861986

19871987
```mlir
19881988
%value = cir.const #cir.int<5> : !s32i
19891989
%index = cir.const #cir.int<2> : !s32i
19901990
%vec_tmp = cir.load %0 : !cir.ptr<!cir.vector<4 x !s32i>>, !cir.vector<4 x !s32i>
1991-
%new_vec = cir.vec.insert %index, %vec_tmp[%value : !s32i] : !cir.vector<4 x !s32i>
1991+
%new_vec = cir.vec.insert %value, %vec_tmp[%index : !s32i] : !cir.vector<4 x !s32i>
19921992
```
19931993
}];
19941994

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ RValue CIRGenFunction::emitLoadOfLValue(LValue lv, SourceLocation loc) {
430430
return RValue::get(emitLoadOfScalar(lv, loc));
431431

432432
if (lv.isVectorElt()) {
433-
auto load =
433+
const mlir::Value load =
434434
builder.createLoad(getLoc(loc), lv.getVectorAddress().getPointer());
435435
return RValue::get(builder.create<cir::VecExtractOp>(getLoc(loc), load,
436436
lv.getVectorIdx()));
@@ -683,12 +683,14 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) {
683683

684684
// Extend or truncate the index type to 32 or 64-bits.
685685
auto ptrTy = mlir::dyn_cast<cir::PointerType>(idx.getType());
686-
if (promote && ptrTy && mlir::isa<cir::IntType>(ptrTy.getPointee()))
686+
if (promote && ptrTy && ptrTy.isPtrTo<cir::IntType>())
687687
cgm.errorNYI(e->getSourceRange(),
688688
"emitArraySubscriptExpr: index type cast");
689689
return idx;
690690
};
691691

692+
// If the base is a vector type, then we are forming a vector element
693+
// with this subscript.
692694
if (e->getBase()->getType()->isVectorType() &&
693695
!isa<ExtVectorElementExpr>(e->getBase())) {
694696
const mlir::Value idx = emitIdxAfterBase(/*promote=*/false);

0 commit comments

Comments
 (0)