[Mlir-commits] [mlir] [mlir][arith] Check for valid IR in BitcastOp::fold. (PR #100743)

Ingo Müller llvmlistbot at llvm.org
Fri Jul 26 08:00:09 PDT 2024


ingomueller-net wrote:

> It's not clear to me when should the folder be resilient to invalid IR though: this is what I mean about "In which context are we folding invalid IR?" ; this is a general question beyond the specific IR you have at hand: I need to know how you end up in this situation instead of the specific invalid IR that triggers this crash.

Oh, got it! This was triggered by a pattern that is part of a dialect conversion that calls a helper function `castTo(OpBuilder&, Type, Value)`, which inserts "the right cast" using `builder.createOrFold<arith::BitcastOp>(...)` like in the unittest. The implementation was erroneous: it did not check for bit widths and inserted `arith.bitcast` even when the types had different bit width.

Does that give you the context you were looking for?

https://github.com/llvm/llvm-project/pull/100743


More information about the Mlir-commits mailing list