Skip to content

Commit

Permalink
Revert "[mlir] ArithToLLVM: fix memref bitcast lowering" (llvm#126895)
Browse files Browse the repository at this point in the history
Reverts llvm#125148

bot failures
  • Loading branch information
Hardcode84 authored and joaosaffran committed Feb 14, 2025
1 parent 04a4dfb commit d5a4429
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 43 deletions.
22 changes: 0 additions & 22 deletions mlir/lib/Conversion/ArithToLLVM/ArithToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,6 @@ struct ConstrainedVectorConvertToLLVMPattern
}
};

/// No-op bitcast. Propagate type input arg if converted source and dest types
/// are the same.
struct IdentityBitcastLowering final
: public OpConversionPattern<arith::BitcastOp> {
using OpConversionPattern::OpConversionPattern;

LogicalResult
matchAndRewrite(arith::BitcastOp op, OpAdaptor adaptor,
ConversionPatternRewriter &rewriter) const final {
Value src = adaptor.getIn();
Type resultType = getTypeConverter()->convertType(op.getType());
if (src.getType() != resultType)
return rewriter.notifyMatchFailure(op, "Types are different");

rewriter.replaceOp(op, src);
return success();
}
};

//===----------------------------------------------------------------------===//
// Straightforward Op Lowerings
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -543,9 +524,6 @@ void mlir::arith::registerConvertArithToLLVMInterface(

void mlir::arith::populateArithToLLVMConversionPatterns(
const LLVMTypeConverter &converter, RewritePatternSet &patterns) {

patterns.add<IdentityBitcastLowering>(converter, patterns.getContext());

// clang-format off
patterns.add<
AddFOpLowering,
Expand Down
10 changes: 1 addition & 9 deletions mlir/lib/Conversion/LLVMCommon/VectorPattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,6 @@ LogicalResult LLVM::detail::handleMultidimensionalVectors(
return success();
}

static bool isVectorCompatibleType(Type type) {
// Limit `vectorOneToOneRewrite` to scalar and vector types (and to
// `LLVM::LLVMArrayType` which have a special handling).
return isa<LLVM::LLVMArrayType, LLVM::LLVMPointerType, VectorType,
IntegerType, FloatType>(type) &&
LLVM::isCompatibleType(type);
}

LogicalResult LLVM::detail::vectorOneToOneRewrite(
Operation *op, StringRef targetOp, ValueRange operands,
ArrayRef<NamedAttribute> targetAttrs,
Expand All @@ -119,7 +111,7 @@ LogicalResult LLVM::detail::vectorOneToOneRewrite(
assert(!operands.empty());

// Cannot convert ops if their operands are not of LLVM type.
if (!llvm::all_of(operands.getTypes(), isVectorCompatibleType))
if (!llvm::all_of(operands.getTypes(), isCompatibleType))
return failure();

auto llvmNDVectorTy = operands[0].getType();
Expand Down
12 changes: 0 additions & 12 deletions mlir/test/Conversion/ArithToLLVM/arith-to-llvm.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -727,15 +727,3 @@ func.func @ops_supporting_overflow(%arg0: i64, %arg1: i64) {
%3 = arith.shli %arg0, %arg1 overflow<nsw, nuw> : i64
return
}

// -----

// CHECK-LABEL: func @memref_bitcast
// CHECK-SAME: (%[[ARG:.*]]: memref<?xi16>)
// CHECK: %[[V1:.*]] = builtin.unrealized_conversion_cast %[[ARG]] : memref<?xi16> to !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)>
// CHECK: %[[V2:.*]] = builtin.unrealized_conversion_cast %[[V1]] : !llvm.struct<(ptr, ptr, i64, array<1 x i64>, array<1 x i64>)> to memref<?xbf16>
// CHECK: return %[[V2]]
func.func @memref_bitcast(%1: memref<?xi16>) -> memref<?xbf16> {
%2 = arith.bitcast %1 : memref<?xi16> to memref<?xbf16>
func.return %2 : memref<?xbf16>
}

0 comments on commit d5a4429

Please sign in to comment.