<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - RISC-V: llvm.fptosi.sat.i32.f32 doesn't work with the +f feature"
   href="https://bugs.llvm.org/show_bug.cgi?id=50083">50083</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>RISC-V: llvm.fptosi.sat.i32.f32 doesn't work with the +f feature
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: RISC-V
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>alex@crichton.co
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>asb@lowrisc.org, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The Rust compiler recently tried to update --
<a href="https://github.com/rust-lang/rust/pull/84339">https://github.com/rust-lang/rust/pull/84339</a> -- to using LLVM's `fptosi` and
`fptoui` saturating intrinsics for all targets, but we found that on the RISC-V
targets with the `+f` target feature LLVM trips an assertion about being unable
to lower. Specifically this LLVM IR:



target triple = "riscv64-unknown-linux-gnu"

define i32 @foo(float %a) #0 {
start:
  %0 = tail call i32 @llvm.fptosi.sat.i32.f32(float %a)
  ret i32 %0
}

declare i32 @llvm.fptosi.sat.i32.f32(float)

attributes #0 = { "target-cpu"="generic-rv64" "target-features"="+f" }





yields:





PromoteIntegerOperand Op #1: t11: i64 = fp_to_sint_sat t3, Constant:i32<32>

Do not know how to promote this operator's operand!
UNREACHABLE executed at
/root/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:1480!
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace.
Stack dump:
0.      Program arguments:
/opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s
-x86-asm-syntax=intel <source>
1.      Running pass 'Function Pass Manager' on module '<source>'.
2.      Running pass 'RISCV DAG->DAG Pattern Instruction Selection' on function
'@foo'</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>