[PATCH] D72544: GlobalISel: Fix assertion on wide G_ZEXT sources
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 15:02:40 PST 2020
arsenm created this revision.
arsenm added reviewers: aemerson, paquette, aditya_nandakumar, dsanders, Petar.Avramovic.
Herald added subscribers: rovka, nhaehnle, wdng, jvesely.
Herald added a project: LLVM.
It's possible to have a type that needs a mask greater than 64-bits.
https://reviews.llvm.org/D72544
Files:
llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-zext.mir
Index: llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-zext.mir
===================================================================
--- llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-zext.mir
+++ llvm/test/CodeGen/AMDGPU/GlobalISel/artifact-combiner-zext.mir
@@ -88,3 +88,28 @@
%2:_(<3 x s32>) = G_ZEXT %1
$vgpr0_vgpr1_vgpr2 = COPY %2
...
+
+# Test for "Too many bits for uint64_t" assertion when combining
+# zexts with wide sources.
+---
+name: test_zext_128_trunc_s128_merge
+body: |
+ bb.0:
+ liveins: $vgpr0_vgpr1
+
+ ; CHECK-LABEL: name: test_zext_128_trunc_s128_merge
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+ ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $vgpr0_vgpr1
+ ; CHECK: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
+ ; CHECK: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 4294967295
+ ; CHECK: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
+ ; CHECK: [[AND1:%[0-9]+]]:_(s64) = G_AND [[COPY1]], [[C1]]
+ ; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[AND]](s64), [[AND1]](s64)
+ ; CHECK: $vgpr0_vgpr1_vgpr2_vgpr3 = COPY [[MV]](s128)
+ %0:_(s64) = COPY $vgpr0_vgpr1
+ %1:_(s64) = COPY $vgpr0_vgpr1
+ %2:_(s128) = G_MERGE_VALUES %0, %1
+ %3:_(s96) = G_TRUNC %2
+ %4:_(s128) = G_ZEXT %3
+ $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %4
+...
Index: llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
===================================================================
--- llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
+++ llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h
@@ -113,7 +113,8 @@
LLVM_DEBUG(dbgs() << ".. Combine MI: " << MI;);
LLT SrcTy = MRI.getType(SrcReg);
APInt Mask = APInt::getAllOnesValue(SrcTy.getScalarSizeInBits());
- auto MIBMask = Builder.buildConstant(DstTy, Mask.getZExtValue());
+ auto MIBMask = Builder.buildConstant(
+ DstTy, Mask.zext(DstTy.getScalarSizeInBits()));
Builder.buildAnd(DstReg, Builder.buildAnyExtOrTrunc(DstTy, TruncSrc),
MIBMask);
markInstAndDefDead(MI, *MRI.getVRegDef(SrcReg), DeadInsts);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72544.237441.patch
Type: text/x-patch
Size: 2147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200110/5cc081b6/attachment.bin>
More information about the llvm-commits
mailing list