Skip to content

Commit

Permalink
[AArch64][GlobalISel] Promote G_UITOFP vector operands to same elt si…
Browse files Browse the repository at this point in the history
…ze as result.

Fixes legalization failures.
  • Loading branch information
aemerson committed Jul 25, 2020
1 parent 34d4c8a commit f320f83
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
Expand Up @@ -399,7 +399,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
getActionDefinitionsBuilder({G_SITOFP, G_UITOFP})
.legalForCartesianProduct({s32, s64, v2s64, v4s32, v2s32})
.clampScalar(1, s32, s64)
.widenScalarToNextPow2(1)
.minScalarSameAs(1, 0)
.clampScalar(0, s32, s64)
.widenScalarToNextPow2(0);

Expand Down
37 changes: 37 additions & 0 deletions llvm/test/CodeGen/AArch64/GlobalISel/legalize-itofp.mir
Expand Up @@ -24,6 +24,9 @@
define void @test_sitofp_v4s32() { ret void }
define void @test_uitofp_v4s32() { ret void }

define void @test_uitofp_v2s64_v2i1() { ret void }
define void @test_sitofp_v2s64_v2i1() { ret void }

define void @test_sitofp_s32_s16() { ret void }
define void @test_uitofp_s32_s16() { ret void }
...
Expand Down Expand Up @@ -239,6 +242,40 @@ body: |
$q0 = COPY %1
...

---
name: test_uitofp_v2s64_v2i1
body: |
bb.0:
liveins: $q0
; CHECK-LABEL: name: test_uitofp_v2s64_v2i1
; CHECK: [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
; CHECK: [[COPY:%[0-9]+]]:_(s1) = COPY [[DEF]](s1)
; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s1>) = G_BUILD_VECTOR [[DEF]](s1), [[COPY]](s1)
; CHECK: [[ZEXT:%[0-9]+]]:_(<2 x s64>) = G_ZEXT [[BUILD_VECTOR]](<2 x s1>)
; CHECK: [[UITOFP:%[0-9]+]]:_(<2 x s64>) = G_UITOFP [[ZEXT]](<2 x s64>)
; CHECK: $q0 = COPY [[UITOFP]](<2 x s64>)
%0:_(<2 x s1>) = G_IMPLICIT_DEF
%1:_(<2 x s64>) = G_UITOFP %0
$q0 = COPY %1
...

---
name: test_sitofp_v2s64_v2i1
body: |
bb.0:
liveins: $q0
; CHECK-LABEL: name: test_sitofp_v2s64_v2i1
; CHECK: [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
; CHECK: [[COPY:%[0-9]+]]:_(s1) = COPY [[DEF]](s1)
; CHECK: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s1>) = G_BUILD_VECTOR [[DEF]](s1), [[COPY]](s1)
; CHECK: [[SEXT:%[0-9]+]]:_(<2 x s64>) = G_SEXT [[BUILD_VECTOR]](<2 x s1>)
; CHECK: [[SITOFP:%[0-9]+]]:_(<2 x s64>) = G_SITOFP [[SEXT]](<2 x s64>)
; CHECK: $q0 = COPY [[SITOFP]](<2 x s64>)
%0:_(<2 x s1>) = G_IMPLICIT_DEF
%1:_(<2 x s64>) = G_SITOFP %0
$q0 = COPY %1
...

---
name: test_sitofp_s32_s16
body: |
Expand Down
Expand Up @@ -407,12 +407,12 @@
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
# DEBUG-NEXT: G_SITOFP (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
# DEBUG-NEXT: G_UITOFP (opcode {{[0-9]+}}): 2 type indices, 0 imm indices
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
# DEBUG-NEXT: .. the first uncovered type index: 2, OK
# DEBUG-NEXT: .. the first uncovered imm index: 0, OK
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
# DEBUG-NEXT: .. imm index coverage check SKIPPED: user-defined predicate detected
# DEBUG-NEXT: G_FABS (opcode {{[0-9]+}}): 1 type index, 0 imm indices
# DEBUG-NEXT: .. opcode {{[0-9]+}} is aliased to {{[0-9]+}}
# DEBUG-NEXT: .. type index coverage check SKIPPED: user-defined predicate detected
Expand Down

0 comments on commit f320f83

Please sign in to comment.