[PATCH] D95567: [AArch64][GlobalISel] Emit G_ASSERT_ZEXT in assignValueToReg
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 1 10:02:57 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf2be5e3bb3d: [AArch64][GlobalISel] Emit G_ASSERT_ZEXT in assignValueToReg (authored by paquette).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D95567/new/
https://reviews.llvm.org/D95567
Files:
llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-zeroext.ll
Index: llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-zeroext.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/GlobalISel/call-lowering-zeroext.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+; RUN: llc -mtriple=aarch64 -global-isel -stop-after=irtranslator -verify-machineinstrs -o - %s | FileCheck %s
+
+; Verify that we generate G_ASSERT_ZEXT for zeroext parameters.
+
+define i8 @zeroext_param_i8(i8 zeroext %x) {
+ ; CHECK-LABEL: name: zeroext_param_i8
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK: liveins: $w0
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
+ ; CHECK: [[ASSERT_ZEXT:%[0-9]+]]:_(s32) = G_ASSERT_ZEXT [[COPY]], 8
+ ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[ASSERT_ZEXT]](s32)
+ ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[TRUNC]](s8)
+ ; CHECK: $w0 = COPY [[ANYEXT]](s32)
+ ; CHECK: RET_ReallyLR implicit $w0
+ ret i8 %x
+}
+
+define i8 @no_zeroext_param(i8 %x) {
+ ; CHECK-LABEL: name: no_zeroext_param
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK: liveins: $w0
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
+ ; CHECK: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[COPY]](s32)
+ ; CHECK: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[TRUNC]](s8)
+ ; CHECK: $w0 = COPY [[ANYEXT]](s32)
+ ; CHECK: RET_ReallyLR implicit $w0
+ ret i8 %x
+}
+
+; Don't need G_ASSERT_ZEXT here. The sizes match.
+define i32 @zeroext_param_i32(i32 zeroext %x) {
+ ; CHECK-LABEL: name: zeroext_param_i32
+ ; CHECK: bb.1 (%ir-block.0):
+ ; CHECK: liveins: $w0
+ ; CHECK: [[COPY:%[0-9]+]]:_(s32) = COPY $w0
+ ; CHECK: $w0 = COPY [[COPY]](s32)
+ ; CHECK: RET_ReallyLR implicit $w0
+ ret i32 %x
+}
Index: llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
===================================================================
--- llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
+++ llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
@@ -74,8 +74,16 @@
default:
MIRBuilder.buildCopy(ValVReg, PhysReg);
break;
+ case CCValAssign::LocInfo::ZExt: {
+ auto WideTy = LLT{VA.getLocVT()};
+ auto NarrowTy = MRI.getType(ValVReg);
+ MIRBuilder.buildTrunc(ValVReg,
+ MIRBuilder.buildAssertZExt(
+ WideTy, MIRBuilder.buildCopy(WideTy, PhysReg),
+ NarrowTy.getSizeInBits()));
+ break;
+ }
case CCValAssign::LocInfo::SExt:
- case CCValAssign::LocInfo::ZExt:
case CCValAssign::LocInfo::AExt: {
auto Copy = MIRBuilder.buildCopy(LLT{VA.getLocVT()}, PhysReg);
MIRBuilder.buildTrunc(ValVReg, Copy);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95567.320510.patch
Type: text/x-patch
Size: 2707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210201/3685d92c/attachment.bin>
More information about the llvm-commits
mailing list