[llvm] add `frexp`/`ldexp` expansion in `ExpandIrInsts` (PR #208556)

Folkert de Vries via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 02:35:33 PDT 2026


folkertdev wrote:

> Other legalizations can plausibly want to emit ldexp or frexp, so I'm not sure we should do that.

Sure, I'm happy to keep it.

> I don't follow how this fixes this case

The expansion in `LegalizeDAG` for `f128` uses `i128`, which is not a legal type at that point (apparently). This was reported in https://github.com/llvm/llvm-project/issues/144006:

```
$ llc -mtriple=aarch64-windows-msvc
define void @f7(ptr %p, i32 %a) {
  %val = load fp128, ptr %p
  %call = tail call fast fp128 @llvm.ldexp.f128(fp128 %val, i32 %a)
  store fp128 %call, ptr %p
  ret void
}

        .def    "@feat.00";
        .scl    3;
        .type   0;
        .endef
        .globl  "@feat.00"
"@feat.00" = 0
        .file   "<stdin>"
llc: [...]llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:985: void (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode *): Assertion `(TLI.getTypeAction(*DAG.getContext(), Op.getValueType()) == TargetLowering::TypeLegal || Op.getOpcode() == ISD::TargetConstant || Op.getOpcode() == ISD::Register) && "Unexpected illegal type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
```

https://github.com/llvm/llvm-project/pull/208556


More information about the llvm-commits mailing list