From 037af52c8bc13a9d92a8a51f5fd9bb61691ffe3d Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Mon, 31 Oct 2016 18:31:09 +0000 Subject: GlobalISel: allow truncating pointer casts on AArch64. llvm-svn: 285615 --- llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp | 2 +- llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'llvm/lib') diff --git a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp index c5777598b65..0dd725ea1d1 100644 --- a/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp @@ -748,6 +748,7 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const { return constrainSelectedInstRegOperands(I, TII, TRI, RBI); } + case TargetOpcode::G_PTRTOINT: case TargetOpcode::G_TRUNC: { const LLT DstTy = MRI.getType(I.getOperand(0).getReg()); const LLT SrcTy = MRI.getType(I.getOperand(1).getReg()); @@ -918,7 +919,6 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const { case TargetOpcode::G_INTTOPTR: - case TargetOpcode::G_PTRTOINT: case TargetOpcode::G_BITCAST: return selectCopy(I, TII, MRI, TRI, RBI); diff --git a/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp index b8f1136b23b..83f276a8161 100644 --- a/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp @@ -169,7 +169,9 @@ AArch64LegalizerInfo::AArch64LegalizerInfo() { setAction({G_FRAME_INDEX, p0}, Legal); setAction({G_GLOBAL_VALUE, p0}, Legal); - setAction({G_PTRTOINT, 0, s64}, Legal); + for (auto Ty : {s1, s8, s16, s32, s64}) + setAction({G_PTRTOINT, 0, Ty}, Legal); + setAction({G_PTRTOINT, 1, p0}, Legal); setAction({G_INTTOPTR, 0, p0}, Legal); -- cgit v1.2.3