Skip to content

[mlir] [arith] -arith-unsigned-when-equivalent crashes in llvm-project/llvm/lib/Support/APInt.cpp:293:int llvm::APInt::compareSigned(const APInt &) const: Assertion `BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"' failed. #107953

Open
@axeabc

Description

@axeabc

git version: 0f50330

system: Ubuntu 18.04.6 LTS

reproduce with: mlir-opt -arith-unsigned-when-equivalent a.mlir

a.mlir:

func.func @test() -> i1 {
  %cst1_i1 = arith.constant 0 : i1
  %0= test.with_bounds { umin = 0 : i64, umax = 12 : i64, smin = 0 : i64, smax = 12 : i64} : i1
  %1= arith.cmpi sgt, %0, %cst1_i1 : i1
  %2= arith.cmpi slt, %0, %cst1_i1 : i1
  %3 = arith.andi %1, %2 : i1
  return %3 : i1
}

stack trace:

mlir-opt: /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/APInt.cpp:293: int llvm::APInt::compareSigned(const APInt &) const: Assertion `BitWidth == RHS.BitWidth && "Bit widths must be same for comparison"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /data/szy/MLIR/llvm-debug/llvm-project/build/bin/mlir-opt -arith-unsigned-when-equivalent a.twXBPBsQjz.mlir
 #0 0x00005596c2857859 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
 #1 0x00005596c2857d0b PrintStackTraceSignalHandler(void*) /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00005596c2855f3f llvm::sys::RunSignalHandlers() /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Signals.cpp:105:5
 #3 0x00005596c28583de SignalHandler(int) /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007f9dfaa23420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007f9dfa06000b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007f9dfa03f859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #7 0x00007f9dfa03f729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #8 0x00007f9dfa03f729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #9 0x00007f9dfa050fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#10 0x00005596c292d7ba llvm::APInt::compareSigned(llvm::APInt const&) const /data/szy/MLIR/llvm-debug/llvm-project/llvm/lib/Support/APInt.cpp:0:3
#11 0x00005596c293893d llvm::APInt::sle(llvm::APInt const&) const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/APInt.h:1159:64
#12 0x00005596c293890d llvm::APInt::sgt(llvm::APInt const&) const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/APInt.h:1194:45
#13 0x00005596cad6e807 isStaticallyTrue(mlir::intrange::CmpPredicate, mlir::ConstantIntRanges const&, mlir::ConstantIntRanges const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp:666:5
#14 0x00005596cad6e655 mlir::intrange::evaluatePred(mlir::intrange::CmpPredicate, mlir::ConstantIntRanges const&, mlir::ConstantIntRanges const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Interfaces/Utils/InferIntRangeCommon.cpp:694:7
#15 0x00005596c2d861db mlir::arith::CmpIOp::inferResultRanges(llvm::ArrayRef<mlir::ConstantIntRanges>, llvm::function_ref<void (mlir::Value, mlir::ConstantIntRanges const&)>) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp:285:36
#16 0x00005596c2d04356 mlir::detail::InferIntRangeInterfaceInterfaceTraits::Model<mlir::arith::CmpIOp>::inferResultRanges(mlir::detail::InferIntRangeInterfaceInterfaceTraits::Concept const*, mlir::Operation*, llvm::ArrayRef<mlir::ConstantIntRanges>, llvm::function_ref<void (mlir::Value, mlir::ConstantIntRanges const&)>) /data/szy/MLIR/llvm-debug/llvm-project/build/tools/mlir/include/mlir/Interfaces/InferIntRangeInterface.h.inc:123:3
#17 0x00005596cbe529c3 mlir::InferIntRangeInterface::inferResultRanges(llvm::ArrayRef<mlir::ConstantIntRanges>, llvm::function_ref<void (mlir::Value, mlir::ConstantIntRanges const&)>) /data/szy/MLIR/llvm-debug/llvm-project/build/tools/mlir/include/mlir/Interfaces/InferIntRangeInterface.cpp.inc:25:7
#18 0x00005596cbe53837 mlir::intrange::detail::defaultInferResultRanges(mlir::InferIntRangeInterface, llvm::ArrayRef<mlir::IntegerValueRange>, llvm::function_ref<void (mlir::Value, mlir::IntegerValueRange const&)>) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Interfaces/InferIntRangeInterface.cpp:164:1
#19 0x00005596c2d04441 mlir::detail::InferIntRangeInterfaceTrait<mlir::arith::CmpIOp>::inferResultRangesFromOptional(llvm::ArrayRef<mlir::IntegerValueRange>, llvm::function_ref<void (mlir::Value, mlir::IntegerValueRange const&)>) /data/szy/MLIR/llvm-debug/llvm-project/build/tools/mlir/include/mlir/Interfaces/InferIntRangeInterface.h.inc:116:5
#20 0x00005596c2d043c6 mlir::detail::InferIntRangeInterfaceInterfaceTraits::Model<mlir::arith::CmpIOp>::inferResultRangesFromOptional(mlir::detail::InferIntRangeInterfaceInterfaceTraits::Concept const*, mlir::Operation*, llvm::ArrayRef<mlir::IntegerValueRange>, llvm::function_ref<void (mlir::Value, mlir::IntegerValueRange const&)>) /data/szy/MLIR/llvm-debug/llvm-project/build/tools/mlir/include/mlir/Interfaces/InferIntRangeInterface.h.inc:127:3
#21 0x00005596cbe52a54 mlir::InferIntRangeInterface::inferResultRangesFromOptional(llvm::ArrayRef<mlir::IntegerValueRange>, llvm::function_ref<void (mlir::Value, mlir::IntegerValueRange const&)>) /data/szy/MLIR/llvm-debug/llvm-project/build/tools/mlir/include/mlir/Interfaces/InferIntRangeInterface.cpp.inc:37:7
#22 0x00005596c7c04170 mlir::dataflow::IntegerRangeAnalysis::visitOperation(mlir::Operation*, llvm::ArrayRef<mlir::dataflow::IntegerValueRangeLattice const*>, llvm::ArrayRef<mlir::dataflow::IntegerValueRangeLattice*>) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlow/IntegerRangeAnalysis.cpp:104:10
#23 0x00005596c2e0d8ad mlir::dataflow::SparseForwardDataFlowAnalysis<mlir::dataflow::IntegerValueRangeLattice>::visitOperationImpl(mlir::Operation*, llvm::ArrayRef<mlir::dataflow::AbstractSparseLattice const*>, llvm::ArrayRef<mlir::dataflow::AbstractSparseLattice*>) /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/Analysis/DataFlow/SparseAnalysis.h:335:12
#24 0x00005596c7c0a625 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitOperation(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp:156:10
#25 0x00005596c7c09d07 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp:70:14
#26 0x00005596c7c09e46 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp:78:20
#27 0x00005596c7c09e46 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp:78:20
#28 0x00005596c7c09cc5 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initialize(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp:63:10
#29 0x00005596c7bbda89 mlir::DataFlowSolver::initializeAndRun(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Analysis/DataFlowFramework.cpp:105:25
#30 0x00005596c2e11d0a (anonymous namespace)::ArithUnsignedWhenEquivalentPass::runOnOperation() /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Dialect/Arith/Transforms/UnsignedWhenEquivalent.cpp:123:23
#31 0x00005596c7c278c4 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:0:17
#32 0x00005596c7c27865 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#33 0x00005596c287b8f9 llvm::function_ref<void ()>::operator()() const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#34 0x00005596c7c2a55b void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRef<mlir::IRUnit>, mlir::Pass&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/include/mlir/IR/MLIRContext.h:276:3
#35 0x00005596c7c234a0 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:533:17
#36 0x00005596c7c239b7 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:593:16
#37 0x00005596c7c252d8 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:904:10
#38 0x00005596c7c2520d mlir::PassManager::run(mlir::Operation*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Pass/Pass.cpp:884:60
#39 0x00005596c7c19b9d performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:413:17
#40 0x00005596c7c19802 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPoolInterface*) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:478:12
#41 0x00005596c7c195fc mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:561:12
#42 0x00005596c7c19596 llvm::LogicalResult llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#43 0x00005596c7d90492 llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) const /data/szy/MLIR/llvm-debug/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#44 0x00005596c7d8faa5 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<llvm::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, llvm::StringRef, llvm::StringRef) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Support/ToolUtilities.cpp:27:12
#45 0x00005596c7c16483 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:564:10
#46 0x00005596c7c16825 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:605:14
#47 0x00005596c7c169f8 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /data/szy/MLIR/llvm-debug/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:621:10
#48 0x00005596c27e1a23 main /data/szy/MLIR/llvm-debug/llvm-project/mlir/tools/mlir-opt/mlir-opt.cpp:317:33
#49 0x00007f9dfa041083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#50 0x00005596c27e164e _start (/data/szy/MLIR/llvm-debug/llvm-project/build/bin/mlir-opt+0x251464e)

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]mlir:arith

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions