Skip to content

Commit

Permalink
[Backend] Fix arith.index_cast lowering to LLVM. (#4704)
Browse files Browse the repository at this point in the history
Fix crash when lowering `arith.index_cast` to llvm when the cast
truncates or extends the i32 index.

`createDestOps` should not `replaceOpWithNewOp` but simply `createOp`
because the call-site (`matchAndRewrite`) calls `replaceOp` later on.
  • Loading branch information
chsigg authored Sep 12, 2024
1 parent 709e3fd commit 4bb928e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,9 @@ struct IndexCastOpLowering
if (targetBits == sourceBits)
return {operands[0][0]};
if (targetBits < sourceBits)
return {rewriter.replaceOpWithNewOp<LLVM::TruncOp>(op, elemTy,
operands[0][0])};
return {
rewriter.replaceOpWithNewOp<LLVM::SExtOp>(op, elemTy, operands[0][0])};
return {
rewriter.create<LLVM::TruncOp>(op.getLoc(), elemTy, operands[0][0])};
return {rewriter.create<LLVM::SExtOp>(op.getLoc(), elemTy, operands[0][0])};
}
};

Expand Down

0 comments on commit 4bb928e

Please sign in to comment.