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

    <tr>
        <th>Summary</th>
        <td>
            [InstCombine] Assertion failure "getting fast-math flag on invalid op"
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            llvm:crash,
            crash
      </td>
    </tr>

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

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

<pre>
    After 060de415af3, a latent bug in instCombine got exposed. 

cat trunk.ll
```
; ModuleID = 'trunk.ll'
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define void @"test"() {
always_continue:
  %0 = load atomic double, ptr addrspace(1) null unordered, align 8
  %1 = load atomic i32, ptr addrspace(1) null unordered, align 4
  %2 = sitofp i32 %1 to double
  %res.i = call noundef double @llvm.minimum.f64(double %0, double %2) #4
  %3 = fcmp ult double %res.i, 0.000000e+00
  %.not16 = icmp eq i32 %1, 0
  %or.cond45 = or i1 %3, %.not16
  call void @llvm.assume(i1 %or.cond45)
  ret void
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare double @llvm.minimum.f64(double, double)

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write)
declare void @llvm.assume(i1 noundef)
```

`opt -passes=instcombine trunk.ll` causes:

```
Assertion failed: (isa<FPMathOperator>(this) && "getting fast-math flag on invalid op"), function hasNoInfs, file Instruction.cpp, line 342.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /Users/anna/llvm-project-fork/installRA/bin/opt -passes=instcombine ip.ll
 #0 0x0000000103221627 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x101905627)
 #1 0x000000010321f875 llvm::sys::RunSignalHandlers() (/Users/anna/llvm-project-fork/installRA/bin/opt+0x101903875)
 #2 0x0000000103221cc0 SignalHandler(int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x101905cc0)
 #3 0x00007ff80cbbe5ed (/usr/lib/system/libsystem_platform.dylib+0x7ff8004255ed)
 #4 0x000000010551a138 llvm::Any::TypeId<llvm::LazyCallGraph::SCC const*>::Id (/Users/anna/llvm-project-fork/installRA/bin/opt+0x103bfe138)
 #5 0x00007ff80cab7b45 (/usr/lib/system/libsystem_c.dylib+0x7ff80031eb45)
 #6 0x00007ff80cab6e5e (/usr/lib/system/libsystem_c.dylib+0x7ff80031de5e)
 #7 0x00000001041d0d53 llvm::Instruction::hasNoInfs() const (.cold.3) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1028b4d53)
 #8 0x000000010292523e llvm::Instruction::hasNoInfs() const (/Users/anna/llvm-project-fork/installRA/bin/opt+0x10100923e)
 #9 0x00000001020cca0e simplifyIntrinsic(llvm::CallBase*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007b0a0e)
#10 0x00000001020cb08e llvm::simplifyCall(llvm::CallBase*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007af08e)
#11 0x00000001020ce873 simplifyInstructionWithOperands(llvm::Instruction*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&, unsigned int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007b2873)
#12 0x00000001020c76c1 simplifyWithOpReplaced(llvm::Value*, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, bool, llvm::SmallVectorImpl<llvm::Instruction*>*, unsigned int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007ab6c1)
#13 0x00000001020c758e simplifyWithOpReplaced(llvm::Value*, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, bool, llvm::SmallVectorImpl<llvm::Instruction*>*, unsigned int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007ab58e)
#14 0x00000001020d2ba7 simplifyAndOrWithICmpEq(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007b6ba7)
#15 0x00000001020c3cf8 simplifyOrInst(llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x1007a7cf8)
#16 0x0000000102c7b917 llvm::InstCombinerImpl::visitOr(llvm::BinaryOperator&) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x10135f917)
#17 0x0000000102c53d5c llvm::InstCombinerImpl::run() (/Users/anna/llvm-project-fork/installRA/bin/opt+0x101337d5c)
#18 0x0000000102c56814 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, bool, llvm::LoopInfo*) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x10133a814)
#19 0x0000000102c56001 llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x10133a001)
#20 0x000000010357ebf2 llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/Users/anna/llvm-project-fork/installRA/bin/opt+0x101c62bf2)
```

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