================ @@ -460,6 +460,28 @@ mlir::LogicalResult CIRToLLVMAssumeOpLowering::matchAndRewrite( return mlir::success(); } +mlir::LogicalResult CIRToLLVMAssumeAlignedOpLowering::matchAndRewrite( + cir::AssumeAlignedOp op, OpAdaptor adaptor, + mlir::ConversionPatternRewriter &rewriter) const { + SmallVector<mlir::Value, 3> opBundleArgs{adaptor.getPointer()}; + + auto alignment = mlir::LLVM::ConstantOp::create( + rewriter, op.getLoc(), rewriter.getI64Type(), adaptor.getAlignment()); + opBundleArgs.push_back(alignment); + + if (mlir::Value offset = adaptor.getOffset()) + opBundleArgs.push_back(offset); + + auto cond = mlir::LLVM::ConstantOp::create(rewriter, op.getLoc(), + rewriter.getI1Type(), 1); + mlir::LLVM::AssumeOp::create(rewriter, op.getLoc(), cond, "align", + opBundleArgs); + rewriter.replaceAllUsesWith(op, op.getPointer()); ---------------- andykaylor wrote:
```suggestion // The LLVM assume doesn't return a value, so we need to update any users of the op result. rewriter.replaceAllUsesWith(op, adaptor.getPointer()); ``` It took me a bit to recognize why this was here, so a comment would be useful. Also, I think using `adaptor.getPointer()` rather than `op.getPointer()` avoids re-lowering the replaced argument since `adaptor.getPointer()` already has it in lowered form. https://github.com/llvm/llvm-project/pull/152152 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits