Skip to content

[SelectionDAG] Legalization crashes for llvm.maximum/minimum #63267

@annamthomas

Description

@annamthomas

Here's a reduced testcase:

declare <4 x half> @llvm.maximum.v4f16(<4 x half>, <4 x half>)
define <4 x half> @fmaximum_v4f16(<4 x half> %x, <4 x half> %y) {
  %r = call <4 x half> @llvm.maximum.v4f16(<4 x half> %x, <4 x half> %y)
  ret <4 x half> %r
}

Similarly, we fail in another case:

declare <2 x fp128> @llvm.maximum.v2f128(<2 x fp128>, <2 x fp128>)
define <2 x fp128> @fmaximum_v2f128(<2 x fp128> %x, <2 x fp128> %y) {
  %r = call <2 x fp128> @llvm.maximum.v2f128(<2 x fp128> %x, <2 x fp128> %y)
  ret <2 x fp128> %r
}

Both of these when run with

llc -mtriple=aarch64-none-linux-gnu -mattr=+neon test.ll

The first fails with:

LLVM ERROR: Cannot select: t12: f16 = fmaximum t38, t33
  t38: f16 = extract_vector_elt t37, Constant:i64<0>
    t37: v8f16 = insert_subvector undef:v8f16, t2, Constant:i64<0>
      t31: v8f16 = undef
      t2: v4f16,ch = CopyFromReg t0, Register:v4f16 %0
        t1: v4f16 = Register %0
      t9: i64 = Constant<0>
    t9: i64 = Constant<0>
  t33: f16 = extract_vector_elt t32, Constant:i64<0>
    t32: v8f16 = insert_subvector undef:v8f16, t4, Constant:i64<0>
      t31: v8f16 = undef
      t4: v4f16,ch = CopyFromReg t0, Register:v4f16 %1
        t3: v4f16 = Register %1
      t9: i64 = Constant<0>
    t9: i64 = Constant<0>
In function: fmaximum_v4f16

The second also fails during ISEL:

LLVM ERROR: Cannot select: t29: f128 = fmaximum t4, t8
  t4: f128,ch = CopyFromReg t0, Register:f128 %1
    t3: f128 = Register %1
  t8: f128,ch = CopyFromReg t0, Register:f128 %3
    t7: f128 = Register %3
In function: fmaximum_v2f128

Working on fix upstream.

Metadata

Metadata

Assignees

Labels

crashPrefer [crash-on-valid] or [crash-on-invalid]llvm:codegen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions