<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/120943>120943</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] -int-range-optimizations crashes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wwy6191
      </td>
    </tr>
</table>

<pre>
    git version: bc29fc937c6cb4a210f80c93c79fc6ed97c801f8

system: `Ubuntu 18.04.6 LTS`

reproduce with: `mlir-opt  -int-range-optimizations 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-release/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-release/llvm-project/build/bin/mlir-opt -int-range-optimizations /data/szy/MLIR/seed/seed29/tmp.twXBPBsQjz.mlir
 #0 0x0000562d78de6508 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ef508)
 #1 0x0000562d78de401e llvm::sys::RunSignalHandlers() (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11ed01e)
 #2 0x0000562d78de6e9d SignalHandler(int) Signals.cpp:0:0
 #3 0x00007fb44a5a7420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fb449be400b raise /build/glibc-LcI20x/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007fb449bc3859 abort /build/glibc-LcI20x/glibc-2.31/stdlib/abort.c:81:7
 #6 0x00007fb449bc3729 get_sysdep_segment_value /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:509:8
 #7 0x00007fb449bc3729 _nl_load_domain /build/glibc-LcI20x/glibc-2.31/intl/loadmsgcat.c:970:34
 #8 0x00007fb449bd4fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #9 0x0000562d78e5d893 (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x1266893)
#10 0x0000562d7e46089d isStaticallyTrue(mlir::intrange::CmpPredicate, mlir::ConstantIntRanges const&, mlir::ConstantIntRanges const&) InferIntRangeCommon.cpp:0:0
#11 0x0000562d7e4607a3 mlir::intrange::evaluatePred(mlir::intrange::CmpPredicate, mlir::ConstantIntRanges const&, mlir::ConstantIntRanges const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x68697a3)
#12 0x0000562d790dcf95 mlir::arith::CmpIOp::inferResultRanges(llvm::ArrayRef<mlir::ConstantIntRanges>, llvm::function_ref<void (mlir::Value, mlir::ConstantIntRanges const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x14e5f95)
#13 0x0000562d7908ca81 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-release/llvm-project/build/bin/mlir-opt+0x1495a81)
#14 0x0000562d7ef24016 mlir::intrange::detail::defaultInferResultRanges(mlir::InferIntRangeInterface, llvm::ArrayRef<mlir::IntegerValueRange>, llvm::function_ref<void (mlir::Value, mlir::IntegerValueRange const&)>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x732d016)
#15 0x0000562d7bd31d3c mlir::dataflow::IntegerRangeAnalysis::visitOperation(mlir::Operation*, llvm::ArrayRef<mlir::dataflow::IntegerValueRangeLattice const*>, llvm::ArrayRef<mlir::dataflow::IntegerValueRangeLattice*>) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x413ad3c)
#16 0x0000562d7bd34df9 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::visitOperation(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x413ddf9)
#17 0x0000562d7bd34499 mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x413d499)
#18 0x0000562d7bd3474d mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x413d74d)
#19 0x0000562d7bd3474d mlir::dataflow::AbstractSparseForwardDataFlowAnalysis::initializeRecursively(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x413d74d)
#20 0x0000562d7bd12b4e mlir::DataFlowSolver::initializeAndRun(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x411bb4e)
#21 0x0000562d7911917d (anonymous namespace)::IntRangeOptimizationsPass::runOnOperation() IntRangeOptimizations.cpp:0:0
#22 0x0000562d7bd47ec6 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4150ec6)
#23 0x0000562d7bd487f0 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x41517f0)
#24 0x0000562d7bd4adc2 mlir::PassManager::run(mlir::Operation*) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4153dc2)
#25 0x0000562d7bd4353a performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#26 0x0000562d7bd4318d 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&) MlirOptMain.cpp:0:0
#27 0x0000562d7bdeec65 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-release/llvm-project/build/bin/mlir-opt+0x41f7c65)
#28 0x0000562d7bd3d175 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x4146175)
#29 0x0000562d7bd3d41f mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414641f)
#30 0x0000562d7bd3d74e mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x414674e)
#31 0x0000562d78dc6ff7 main (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfff7)
#32 0x00007fb449bc5083 __libc_start_main /build/glibc-LcI20x/glibc-2.31/csu/../csu/libc-start.c:342:3
#33 0x0000562d78dc6b6e _start (/data/szy/MLIR/llvm-release/llvm-project/build/bin/mlir-opt+0x11cfb6e)
``` 
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWt1u27gSfhrlhohBkfq9yIWS1tgADZKT9PzcGRRJ2dyVSB2SSuI-_QEp2ZJVu027dYuzu9jGEjXDme-b4WgoiRgj1pLzqyC-DuJ3F6SzG6WvXl62SZiHF6Vi26u1sOCZayOUDHABSoryiuY4pQktI4JCWGWQ5pimeUUTzvKUZjCssgAWASzM1ljeOL0ggf8sO2k7EGYLGC0S8OHjU5DAXk7zVivWUQ5ehN0M8k0t9KVqLQCXQtpLTeSau3PRiE_ECiUNIAsntJ8mgMUwggsA3EAC-__dSdVJunB_QBBBy40NUBagHFwG-D0QIQjS6wA6PRRTY8OVG8LvANHCbhZUSWOJtAACN7kId6LQybjZFs71Vak6yYybC3SNkH6GQSWJAnQDuoa8-tEQTYfNUWFzRDh9N_MgnHjZtAKYtXW63rf-d4Qz1UNzvfptenhCC5FM9D70Gmgqq7nttNypDMNB-m4I1jQ2xhL6B7CaUB7g4ojALhl8bqAlI5YEaGk-bQO0vPtw-xigZV0_N5ea15wYvjtttfqdUzucuh9RBmj51LWt0m64eLiVdkHbNsAFyrF3U1rgpXER4MIL9IdUNS3R_MmtGRagzOcE8AIgQInLJT_kJimM4dolqcvka2H_LZjdOOIcd4-_PS3GMaeZgACha2HBixszoOmMBSUHhjQcVEqD3rYwSgYI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