[all-commits] [llvm/llvm-project] 0605e9: [SDISel][Builder] Fix the instantiation of <1 x bf...

Quentin Colombet via All-commits all-commits at lists.llvm.org
Fri Jun 7 09:47:58 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0605e984fab700a6ef4affc3fdb66aaba3417baa
      https://github.com/llvm/llvm-project/commit/0605e984fab700a6ef4affc3fdb66aaba3417baa
  Author: Quentin Colombet <quentin.colombet at gmail.com>
  Date:   2024-06-07 (Fri, 07 Jun 2024)

  Changed paths:
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    A llvm/test/CodeGen/AMDGPU/select-phi-s16-fp.ll
    M llvm/test/CodeGen/ARM/arm-half-promote.ll
    A llvm/test/CodeGen/X86/select-phi-s16-fp.ll

  Log Message:
  -----------
  [SDISel][Builder] Fix the instantiation of <1 x bfloat|half> (#94591)

Prior to this change, `SelectionDAGBuilder` was producing `SDNode`s of
the form: `f32 = extract_vector_elt <1 x bfloat|half>, i32 0` when
lowering phis of `<1 x bfloat|half>` and running on a target that
promotes this type to `f32` (like some x86 or AMDGPU targets.)

This construct is invalid since this type of node only allows type
extensions for integer types.
It went unotice because the `extract_vector_elt` node is later broken
down in `bitcast` followed by `bf16_to_fp|fp_extend`. However, when the
argument of the phi is a constant we were crashing because the existing
code would try to constant fold this `extract_vector_elt` into a
any_ext.

This patch fixes this by using a proper decomposition for `<1 x
bfloat|half>`:
```
bfloat|half = bitcast <1 x blfoat|half>
float = fp_extend bfloat|half
```

This change should be NFC for the non-constant-folding cases and fix the
SDISel crashes (reported in
https://github.com/llvm/llvm-project/issues/94449) for the folding
cases.

Note: The change on the arm test is a missing fp16 to f32 constant folding
exposed by this patch. I'll push a separate improvement for that.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list