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

    <tr>
        <th>Summary</th>
        <td>
            [mlir] --llvm-type-consistency crashed in mlir::LLVM::CanonicalizeAlignedGep::matchAndRewrite with assertion failure "Integer has bits outside those preserved!".
        </td>
    </tr>

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

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

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

<pre>
    git version: 383e35048e16c85ab26bc46822d3ceb11fd4d3f2

system: Ubuntu 20.04.6 LTS (Focal Fossa)

reproduced with: ```mlir-opt --llvm-type-consistency a.mlir```

a.mlir:
```
llvm.func @func2() {
  %43 = llvm.mlir.constant(29 : index) : i64
  %91 = llvm.mlir.constant(3.964800e+04 : f16) : f16
  %32 = llvm.mlir.constant(false) : i1
  %136 = llvm.mlir.zero : !llvm.ptr
 %137 = llvm.getelementptr %136[%43] : (!llvm.ptr, i64) -> !llvm.ptr, f32
 %250 = llvm.mlir.undef : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)>
  %327 = scf.if %32 -> (f16) {
    %429 = memref.alloca_scope -> (memref<?x?x11xf16>) {
      %446 = llvm.getelementptr %137[-1] : (!llvm.ptr) -> !llvm.ptr, f16  // negative index
      llvm.store %91, %446 : f16, !llvm.ptr
      %474 = llvm.insertvalue %43, %250[3, 0] : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> 
      %480 = builtin.unrealized_conversion_cast %474 : !llvm.struct<(ptr, ptr, i64, array<3 x i64>, array<3 x i64>)> to memref<?x?x11xf16>
 memref.alloca_scope.return %480 : memref<?x?x11xf16>
    }
 scf.yield %91 : f16
  } else {
    scf.yield %91 : f16
  }
 llvm.return 
}
```



trace:
```
mlir-opt: /data/bin1/llvm-project/llvm/include/llvm/ADT/PointerEmbeddedInt.h:64: llvm::PointerEmbeddedInt<IntT, Bits>& llvm::PointerEmbeddedInt<IntT, Bits>::operator=(IntT) [with IntT = int; int Bits = 29]: Assertion `(std::is_signed<IntT>::value ? isInt<Bits>(I) : isUInt<Bits>(I)) && "Integer has bits outside those preserved!"' 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/bin1/llvm-project/build/bin/mlir-opt --llvm-type-consistency a.mlir
 #0 0x0000559f5a0b93ff llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/data/bin1/llvm-project/build/bin/mlir-opt+0x16573ff)
 #1 0x0000559f5a0b6454 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fa54dad3420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007fa54d5be00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007fa54d59d859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007fa54d59d729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007fa54d5aefd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x0000559f5ae38908 mlir::LLVM::CanonicalizeAlignedGep::matchAndRewrite(mlir::LLVM::GEPOp, mlir::PatternRewriter&) const (/data/bin1/llvm-project/build/bin/mlir-opt+0x23d6908)
 #8 0x0000559f5ae34c0a mlir::detail::OpOrInterfaceRewritePatternBase<mlir::LLVM::GEPOp>::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&) const (/data/bin1/llvm-project/build/bin/mlir-opt+0x23d2c0a)
 #9 0x0000559f5fab0e98 mlir::PatternApplicator::matchAndRewrite(mlir::Operation*, mlir::PatternRewriter&, llvm::function_ref<bool (mlir::Pattern const&)>, llvm::function_ref<void (mlir::Pattern const&)>, llvm::function_ref<mlir::LogicalResult (mlir::Pattern const&)>) (/data/bin1/llvm-project/build/bin/mlir-opt+0x704ee98)
#10 0x0000559f5ce0f8ac (anonymous namespace)::GreedyPatternRewriteDriver::processWorklist() GreedyPatternRewriteDriver.cpp:0:0
#11 0x0000559f5ce13d1b mlir::applyPatternsAndFoldGreedily(mlir::Region&, mlir::FrozenRewritePatternSet const&, mlir::GreedyRewriteConfig, bool*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x43b1d1b)
#12 0x0000559f5ae360bc (anonymous namespace)::LLVMTypeConsistencyPass::runOnOperation() TypeConsistency.cpp:0:0
#13 0x0000559f5cd59f3e mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f7f3e)
#14 0x0000559f5cd5a41a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f841a)
#15 0x0000559f5cd5ae1c mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::'lambda'(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&)::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const Pass.cpp:0:0
#16 0x0000559f5cd59575 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f7575)
#17 0x0000559f5cd59cda mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f7cda)
#18 0x0000559f5cd5a41a mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f841a)
#19 0x0000559f5cd5ac44 mlir::PassManager::run(mlir::Operation*) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42f8c44)
#20 0x0000559f5cd4b9b3 performActions(llvm::raw_ostream&, std::shared_ptr<llvm::SourceMgr> const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) MlirOptMain.cpp:0:0
#21 0x0000559f5cd4ce84 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) MlirOptMain.cpp:0:0
#22 0x0000559f5cd4d034 mlir::LogicalResult llvm::function_ref<mlir::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&)::'lambda'(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&) MlirOptMain.cpp:0:0
#23 0x0000559f5ce4c324 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) (/data/bin1/llvm-project/build/bin/mlir-opt+0x43ea324)
#24 0x0000559f5cd45897 mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_delete<llvm::MemoryBuffer>>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42e3897)
#25 0x0000559f5cd4d181 mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42eb181)
#26 0x0000559f5cd4d5e6 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) (/data/bin1/llvm-project/build/bin/mlir-opt+0x42eb5e6)
#27 0x0000559f59ff0a7b main (/data/bin1/llvm-project/build/bin/mlir-opt+0x158ea7b)
#28 0x00007fa54d59f083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#29 0x0000559f5a08975e _start (/data/bin1/llvm-project/build/bin/mlir-opt+0x162775e)
Aborted (core dumped)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1T4zjW_jXmRkVKlvx5wUVIyLxUNQXV9Lx7mZKl46BtR_ZKMkPm129JdhLbEKAHpndma6u6Q2wfPXrOp46sMGPkRgFcBPFlEC_PWGsfan3BVK1227o1N4v7s6IWu4uNtOgRtJG1Cugc0YwCjXGUQZjwLGYFSQoeJRkhgnIowrAUkaAlCfAywPPu0-yMha0b_WvRKtsigmc4miXoy7d7FJBsVXNWoVVtDAtIPhypodG1aDkI9Ju0Dw4iSHD3b1tJfV43Fp2fV9Xj9tzuGjjntTLSWFB8h9jMiRzkh7j9I9pfTmQc3KxsFUdBhN1fEpAsIDkK0stOAqGAxBFFAV0iL-3gZm5yy5QNSOaE6RxJJeAp2F8k0WB0Hp4eTWd5EmUYQ0AuceQHl2Gyx3FfjziUnMYpWWXgMH04GBXSZDLsd9C1lwtI6O82VvcDvHx6lN-AhQq2oGxjdY_mwsiZJIiXPUo2BCILrz7J0XlAr9DkUUnJcSoS4wm1VgkoR9yM1S23AV0EJOsxhrMsENOa7QK6oOjJ36JXp-7m7nNozk5Rw8uZLHsD95yzvROOYdAFgrfwEm1hq6GcsaqqOVsbXjdwGNo9c4zp6sn9D8MnB-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