Invalid lowering of llvm.*.f128 intrinsics · Issue #44744 · llvm/llvm-project (original) (raw)

Bugzilla Link 45399
Version trunk
OS Linux

Extended Description

llvm.sin.f128 is incorrectly lowered to a call to sinl, which takes a f80: https://godbolt.org/z/M9fjLW

define fp128 @​bad_lowering(fp128 %a) {
  %s = call fp128 @​llvm.sin.f128(fp128 %a)
  ret fp128 %s
}

generates:

which is missing conversions from and to x86_fp80.

I expect a correct lowering to be:

define fp128 @​manual_correct_lowering(fp128 %a) {
  %t = fptrunc fp128 %a to x86_fp80
  %s = call x86_fp80 @​llvm.sin.f80(x86_fp80 %t)
  %e = fpext x86_fp80 %s to fp128
  ret fp128 %e
}
manual_correct_lowering:
  subq $24, %rsp
  callq __trunctfxf2
  fstpt (%rsp)
  callq sinl
  fstpt (%rsp)
  callq __extendxftf2
  addq $24, %rsp
  retq