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

    <tr>
        <th>Summary</th>
        <td>
            opt -O2 crash Assertion `(Value == 0 || llvm::isPowerOf2_64(Value)) && "Alignment is neither 0 nor a power of 2"' failed, but works under `instcombine`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    Here is the link:
https://godbolt.org/z/M1ahz5KxY

Source code
```
declare void @llvm.assume(i1 noundef)

define i8 @assume_align_non_pow2(ptr %p) {
  call void @llvm.assume(i1 true) [ "align"(ptr %p, i64 123) ]
  %v = load i8, ptr %p
  ret i8 %v
}
```

This test case comes from:
https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/InstCombine/assume-align.ll

Is this crash an intentional behavior? I submitted this issue because this function doesn't trigger crashes under `instcombine`

Error message:
```
opt: /root/llvm-project/llvm/include/llvm/Support/Alignment.h:134: llvm::MaybeAlign::MaybeAlign(uint64_t): Assertion `(Value == 0 || llvm::isPowerOf2_64(Value)) && "Alignment is neither 0 nor a power of 2"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -O2 <source>
 #0 0x0000000003487758 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x3487758)
 #1 0x000000000348504c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f70155a6420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f701506900b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f7015048859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f7015048729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f7015059fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x00000000040c5187 getNewAlignmentDiff(llvm::SCEV const*, llvm::SCEV const*, llvm::ScalarEvolution*) AlignmentFromAssumptions.cpp:0:0
 #8 0x00000000040c56f8 getNewAlignment(llvm::SCEV const*, llvm::SCEV const*, llvm::SCEV const*, llvm::Value*, llvm::ScalarEvolution*) AlignmentFromAssumptions.cpp:0:0
 #9 0x00000000040c672c llvm::AlignmentFromAssumptionsPass::processAssumption(llvm::CallInst*, unsigned int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c672c)
#10 0x00000000040c7a77 llvm::AlignmentFromAssumptionsPass::runImpl(llvm::Function&, llvm::AssumptionCache&, llvm::ScalarEvolution*, llvm::DominatorTree*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c7a77)
#11 0x00000000040c7c21 llvm::AlignmentFromAssumptionsPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40c7c21)
#12 0x000000000369c55e llvm::detail::PassModel<llvm::Function, llvm::AlignmentFromAssumptionsPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x369c55e)
#13 0x0000000000d3fa9d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd3fa9d)
#14 0x0000000002df4ade llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2df4ade)
#15 0x0000000000d2459e llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd2459e)
#16 0x0000000002df2adc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2df2adc)
#17 0x0000000000887d2a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x887d2a)
#18 0x000000000078e0c1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x78e0c1)
#19 0x00007f701504a083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#20 0x000000000087cf6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x87cf6e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWE1v2zoW_TX0hrBBUd8LL1wnfg3eyzSYBAVmZVDSlcwJRQoklY_36wekFMdynCJpPUAxU7h2JF4e3nPuIUWRGcMbCbBE8RcUX8xYb3dKL78ya3oJpuMlmxWqel5-BQ2YG2x3gAWX9yhcIXKByGpnbWfcFd0gumlUVShhF0o3iG7-RnRzHbDd3_GfT_8awofvW9XrEnCpKhhvJ2T8-MsKSsE04AfFK4wiIsRDu2DG9C0gmvEAS9XLCmpE80PYCmouAfPM9RnCt0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