Skip to content

Commit 21b9ca8

Browse files
committed
Addressing review feedback
1 parent ab0d2d5 commit 21b9ca8

File tree

5 files changed

+41
-87
lines changed

5 files changed

+41
-87
lines changed

llvm/lib/CodeGen/MachineVerifier.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,18 +1276,8 @@ void MachineVerifier::verifyPreISelGenericInstruction(const MachineInstr *MI) {
12761276
report("load memory size cannot exceed result size", MI);
12771277

12781278
if (MMO.getRanges()) {
1279-
auto operandBits = [](const MDOperand &o) -> unsigned {
1280-
ConstantInt *i = mdconst::extract<ConstantInt>(o);
1281-
if (!i->isNegative())
1282-
return i->getValue().getActiveBits();
1283-
APInt reversed(i->getValue());
1284-
reversed.negate();
1285-
return reversed.getActiveBits() + 1; // one more bit for the sign
1286-
};
1287-
unsigned bitsUsed =
1288-
std::max(operandBits(MMO.getRanges()->getOperand(0)),
1289-
operandBits(MMO.getRanges()->getOperand(1)));
1290-
if (bitsUsed != ValTy.getScalarType().getSizeInBits()) {
1279+
ConstantInt *i = mdconst::extract<ConstantInt>(MMO.getRanges()->getOperand(0));
1280+
if (i->getIntegerType()->getBitWidth() != ValTy.getScalarType().getSizeInBits()) {
12911281
report("range is incompatible with the value it gets assigned to",
12921282
MI);
12931283
}

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-load-memory-metadata.mir

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
!0 = !{i24 0, i24 1048575}
3131
!1 = !{!"omnipotent char", !2}
3232
!2 = !{!"Simple C/C++ TBAA"}
33+
!3 = !{i32 0, i32 1048575}
3334
...
3435

3536
# Make sure range metadata is not preserved when widening loads, but
@@ -67,7 +68,7 @@ body: |
6768
; SI-NEXT: [[LOAD:%[0-9]+]]:_(s32) = G_LOAD [[COPY]](p1) :: (load (s32), !tbaa !1, addrspace 1)
6869
; SI-NEXT: $vgpr0 = COPY [[LOAD]](s32)
6970
%0:_(p1) = COPY $vgpr0_vgpr1
70-
%1:_(s32) = G_LOAD %0 :: (load (s24), align 4, addrspace 1, !range !0, !tbaa !1)
71+
%1:_(s32) = G_LOAD %0 :: (load (s24), align 4, addrspace 1, !range !3, !tbaa !1)
7172
$vgpr0 = COPY %1
7273
7374
...

llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-split-scalar-load-metadata.mir

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
!0 = !{i96 0, i96 9223372036854775808}
1818
!1 = !{!"omnipotent char", !2}
1919
!2 = !{!"Simple C/C++ TBAA"}
20+
!3 = !{i32 0, i32 4294967295}
2021
...
2122

2223
# Make sure range metadata is not preserved when widening loads, but
@@ -44,10 +45,10 @@ body: |
4445
; GFX12: liveins: $sgpr0_sgpr1
4546
; GFX12-NEXT: {{ $}}
4647
; GFX12-NEXT: [[COPY:%[0-9]+]]:sgpr(p4) = COPY $sgpr0_sgpr1
47-
; GFX12-NEXT: [[LOAD:%[0-9]+]]:sgpr(<3 x s32>) = G_LOAD [[COPY]](p4) :: (load (<3 x s32>), align 8, !range !0, addrspace 4)
48+
; GFX12-NEXT: [[LOAD:%[0-9]+]]:sgpr(<3 x s32>) = G_LOAD [[COPY]](p4) :: (load (<3 x s32>), align 8
4849
; GFX12-NEXT: $sgpr0_sgpr1_sgpr2 = COPY [[LOAD]](<3 x s32>)
4950
%0:_(p4) = COPY $sgpr0_sgpr1
50-
%1:_(<3 x s32>) = G_LOAD %0 :: (load (<3 x s32>), align 8, addrspace 4, !range !0)
51+
%1:_(<3 x s32>) = G_LOAD %0 :: (load (<3 x s32>), align 8, addrspace 4, !range !3)
5152
$sgpr0_sgpr1_sgpr2 = COPY %1
5253
5354
...
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# RUN: not --crash llc -mtriple=amdgcn-mesa-mesa3d -mcpu=tahiti -run-pass=none %s -filetype=null 2>&1 | FileCheck %s
2+
--- |
3+
define void @range_metadata_sext_i33_signed_range_i64_load_as_v2i32() {
4+
ret void
5+
}
6+
7+
!0 = !{i64 -4294967295, i64 4294967296}
8+
!1 = !{i64 -8589934591, i64 8589934592}
9+
10+
...
11+
---
12+
name: range_metadata_sext_i33_signed_range_i64_load_as_v2i32
13+
tracksRegLiveness: true
14+
body: |
15+
bb.0:
16+
liveins: $vgpr0, $vgpr1
17+
18+
%1:_(s32) = COPY $vgpr0
19+
%2:_(s32) = COPY $vgpr1
20+
%0:_(p1) = G_MERGE_VALUES %1(s32), %2(s32)
21+
22+
; CHECK: Bad machine code: range is incompatible with the value it gets assigned to
23+
%3:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !1, addrspace 1)
24+
25+
; CHECK: Bad machine code: range is incompatible with the value it gets assigned to
26+
%4:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1)
27+
28+
; CHECK: Bad machine code: range is incompatible with the value it gets assigned to
29+
%5:_(<2 x s32>) = G_LOAD %0(p1) :: (volatile load (s64), align 4, !range !0, addrspace 1)
30+
31+
$vgpr0_vgpr1 = COPY %3
32+
SI_RETURN implicit $vgpr0_vgpr1
33+
34+
...

llvm/test/MachineVerifier/test_g_load_vector_to_scalar.mir

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)