Skip to content

FMA primops produces an invalid LLVM opcode

Summary

The same program as #24160 (closed) produces an error in LLVM Optimizer.

$ ghc -fforce-recomp -fllvm -mfma -O2 TwoProdFMA.hs
[1 of 1] Compiling TwoProdFMA       ( TwoProdFMA.hs, TwoProdFMA.o )
opt-15: /tmp/ghc538906_0/ghc_1.ll:81:11: error: expected instruction opcode
  %lnCX = fmsub float %lnCU, %lnCV, %lnCW
          ^

<no location info>: error:
    `opt-15' failed in phase `LLVM Optimiser'. (Exit code: 1)

Steps to reproduce

Compile the following program with -fllvm -mfma:

{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
module TwoProdFMA where
import GHC.Exts

twoProductFloat# :: Float# -> Float# -> (# Float#, Float# #)
twoProductFloat# x y = let !r = x `timesFloat#` y
                       in (# r, fmsubFloat# x y r #)

Expected behavior

The program should compile without error.

Environment

  • GHC version used: 9.9.20231124 (34d86315) and 9.8.1
    • With LLVM 15
  • Operating System: Ubuntu 22.04
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information