[llvm] r370627 - [AArch64][GlobalISel] Fix zext narrowScalar to use the right type when creating
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 2 01:18:56 PDT 2019
Author: aemerson
Date: Mon Sep 2 01:18:55 2019
New Revision: 370627
URL: http://llvm.org/viewvc/llvm-project?rev=370627&view=rev
Log:
[AArch64][GlobalISel] Fix zext narrowScalar to use the right type when creating
the merges.
Fixes PR43171.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-sext-zext-128.mir
Modified: llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp?rev=370627&r1=370626&r2=370627&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/LegalizerHelper.cpp Mon Sep 2 01:18:55 2019
@@ -620,13 +620,15 @@ LegalizerHelper::LegalizeResult Legalize
if (TypeIdx != 0)
return UnableToLegalize;
- if (SizeOp0 % NarrowTy.getSizeInBits() != 0)
+ LLT SrcTy = MRI.getType(MI.getOperand(1).getReg());
+ uint64_t SizeOp1 = SrcTy.getSizeInBits();
+ if (SizeOp0 % SizeOp1 != 0)
return UnableToLegalize;
// Generate a merge where the bottom bits are taken from the source, and
// zero everything else.
- Register ZeroReg = MIRBuilder.buildConstant(NarrowTy, 0).getReg(0);
- unsigned NumParts = SizeOp0 / NarrowTy.getSizeInBits();
+ Register ZeroReg = MIRBuilder.buildConstant(SrcTy, 0).getReg(0);
+ unsigned NumParts = SizeOp0 / SizeOp1;
SmallVector<Register, 4> Srcs = {MI.getOperand(1).getReg()};
for (unsigned Part = 1; Part < NumParts; ++Part)
Srcs.push_back(ZeroReg);
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-sext-zext-128.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-sext-zext-128.mir?rev=370627&r1=370626&r2=370627&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-sext-zext-128.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/legalize-sext-zext-128.mir Mon Sep 2 01:18:55 2019
@@ -46,6 +46,28 @@ body: |
...
---
+name: narrow_zext_s128_from_s32
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $w0, $x1
+
+ ; CHECK-LABEL: name: narrow_zext_s128_from_s32
+ ; CHECK: liveins: $w0, $x1
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
+ ; CHECK: [[COPY1:%[0-9]+]]:_(p0) = COPY $x1
+ ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
+ ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[COPY]](s32), [[C]](s32), [[C]](s32), [[C]](s32)
+ ; CHECK: G_STORE [[MV]](s128), [[COPY1]](p0) :: (store 16)
+ ; CHECK: RET_ReallyLR
+ %0:_(s32) = COPY $w0
+ %1:_(p0) = COPY $x1
+ %2:_(s128) = G_ZEXT %0(s32)
+ G_STORE %2(s128), %1(p0) :: (store 16)
+ RET_ReallyLR
+
+...
+---
name: narrow_zext_s192
tracksRegLiveness: true
body: |
More information about the llvm-commits
mailing list