Skip to content

Commit befee40

Browse files
committed
GlobalISel: Implement widenScalar for implicit_def
llvm-svn: 350695
1 parent 4615a50 commit befee40

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,12 @@ LegalizerHelper::widenScalar(MachineInstr &MI, unsigned TypeIdx, LLT WideTy) {
884884
Observer.changedInstr(MI);
885885
return Legalized;
886886
}
887+
case TargetOpcode::G_IMPLICIT_DEF: {
888+
Observer.changingInstr(MI);
889+
widenScalarDst(MI, WideTy);
890+
Observer.changedInstr(MI);
891+
return Legalized;
892+
}
887893
case TargetOpcode::G_BRCOND:
888894
Observer.changingInstr(MI);
889895
widenScalarSrc(MI, WideTy, 0, TargetOpcode::G_ANYEXT);

llvm/test/CodeGen/AArch64/GlobalISel/legalize-undef.mir

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
# RUN: llc -march=aarch64 -run-pass=legalizer %s -o - | FileCheck %s
2+
# RUN: llc -march=aarch64 -run-pass=legalizer -O0 %s -o - | FileCheck %s
33
---
44
name: test_implicit_def
55
body: |
@@ -16,3 +16,22 @@ body: |
1616
%1:_(s64) = G_TRUNC %0(s128)
1717
$x0 = COPY %1(s64)
1818
...
19+
20+
---
21+
name: test_implicit_def_s3
22+
body: |
23+
bb.0:
24+
liveins:
25+
26+
; CHECK-LABEL: name: test_implicit_def_s3
27+
; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 61
28+
; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
29+
; CHECK: [[SHL:%[0-9]+]]:_(s64) = G_SHL [[DEF]], [[C]]
30+
; CHECK: [[ASHR:%[0-9]+]]:_(s64) = G_ASHR [[SHL]], [[C]]
31+
; CHECK: $x0 = COPY [[ASHR]](s64)
32+
%0:_(s3) = G_IMPLICIT_DEF
33+
%1:_(s64) = G_SEXT %0
34+
$x0 = COPY %1(s64)
35+
...
36+
37+
# FIXME: s2 not correctly handled

0 commit comments

Comments
 (0)