Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ class CIRPtrStrideOpLowering
// before it. To achieve that, look at unary minus, which already got
// lowered to "sub 0, x".
auto sub = dyn_cast<mlir::LLVM::SubOp>(indexOp);
auto unary =
dyn_cast<mlir::cir::UnaryOp>(ptrStrideOp.getStride().getDefiningOp());
auto unary = dyn_cast_if_present<mlir::cir::UnaryOp>(
ptrStrideOp.getStride().getDefiningOp());
bool rewriteSub =
unary && unary.getKind() == mlir::cir::UnaryOpKind::Minus && sub;
if (rewriteSub)
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CIR/Lowering/ptrstride.cir
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// RUN: cir-opt %s -cir-to-llvm -o %t.mlir
// RUN: FileCheck %s --input-file=%t.mlir -check-prefix=MLIR
// XFAIL:*

!s32i = !cir.int<s, 32>
module {
Expand Down Expand Up @@ -31,4 +30,5 @@ module {
// MLIR: llvm.return

// MLIR-LABEL: @g
// MLIR: llvm.getelementptr %arg0[%arg1] : (!llvm.ptr, i32) -> !llvm.ptr, i32
// MLIR: %0 = llvm.sext %arg1 : i32 to i64
// MLIR-NEXT: llvm.getelementptr %arg0[%0] : (!llvm.ptr, i64) -> !llvm.ptr, i32