From 8ff49ec2ed021b09fb0fb0d75424e232729668b6 Mon Sep 17 00:00:00 2001 From: Christian Sigg Date: Wed, 11 Sep 2024 17:43:06 +0200 Subject: [PATCH] [Backend] Fix arith.index_cast lowering to LLVM. 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. --- lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp b/lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp index 0287207be51a..787dee35fb25 100644 --- a/lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp +++ b/lib/Conversion/TritonGPUToLLVM/ElementwiseOpToLLVM.cpp @@ -610,10 +610,9 @@ struct IndexCastOpLowering if (targetBits == sourceBits) return {operands[0][0]}; if (targetBits < sourceBits) - return {rewriter.replaceOpWithNewOp(op, elemTy, - operands[0][0])}; - return { - rewriter.replaceOpWithNewOp(op, elemTy, operands[0][0])}; + return { + rewriter.create(op.getLoc(), elemTy, operands[0][0])}; + return {rewriter.create(op.getLoc(), elemTy, operands[0][0])}; } };