Skip to content

Commit aaf2d27

Browse files
committed
Don't merge icmps derived from pointers with addressspaces
IIUC we can't emit `memcmp` between pointers in addressspaces, doing so will trigger an assertion since the signature of the memcmp will not match it's arguments (https://bugs.llvm.org/show_bug.cgi?id=48661). This PR disables the attempt to merge icmps, when the pointer is in an addressspace. Differential Revision: https://reviews.llvm.org/D94813 (cherry picked from commit 458b259)
1 parent 6411a50 commit aaf2d27

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt < %s -mergeicmps -S | FileCheck %s
3+
4+
source_filename = "=="
5+
target datalayout = "e-m:e-i64:64-n32:64"
6+
target triple = "powerpc64le-unknown-linux-gnu"
7+
8+
define void @juliaAS([2 x [5 x i64]] addrspace(11)* nocapture nonnull readonly align 8 dereferenceable(80) %0, [2 x [5 x i64]] addrspace(11)* nocapture nonnull readonly align 8 dereferenceable(80) %1) {
9+
; CHECK-LABEL: @juliaAS(
10+
; CHECK-NEXT: top:
11+
; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* [[TMP0:%.*]], i64 0, i64 1, i64 2
12+
; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* [[TMP0]], i64 0, i64 1, i64 3
13+
; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* [[TMP0]], i64 0, i64 1, i64 4
14+
; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* [[TMP1:%.*]], i64 0, i64 1, i64 2
15+
; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* [[TMP1]], i64 0, i64 1, i64 3
16+
; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* [[TMP1]], i64 0, i64 1, i64 4
17+
; CHECK-NEXT: [[TMP8:%.*]] = load i64, i64 addrspace(11)* [[TMP2]], align 8
18+
; CHECK-NEXT: [[TMP9:%.*]] = load i64, i64 addrspace(11)* [[TMP5]], align 8
19+
; CHECK-NEXT: [[DOTNOT17:%.*]] = icmp eq i64 [[TMP8]], [[TMP9]]
20+
; CHECK-NEXT: br i1 [[DOTNOT17]], label [[L70:%.*]], label [[L90:%.*]]
21+
; CHECK: L70:
22+
; CHECK-NEXT: [[TMP10:%.*]] = load i64, i64 addrspace(11)* [[TMP3]], align 8
23+
; CHECK-NEXT: [[TMP11:%.*]] = load i64, i64 addrspace(11)* [[TMP6]], align 8
24+
; CHECK-NEXT: [[DOTNOT18:%.*]] = icmp eq i64 [[TMP10]], [[TMP11]]
25+
; CHECK-NEXT: br i1 [[DOTNOT18]], label [[L74:%.*]], label [[L90]]
26+
; CHECK: L74:
27+
; CHECK-NEXT: [[TMP12:%.*]] = load i64, i64 addrspace(11)* [[TMP4]], align 8
28+
; CHECK-NEXT: [[TMP13:%.*]] = load i64, i64 addrspace(11)* [[TMP7]], align 8
29+
; CHECK-NEXT: [[DOTNOT19:%.*]] = icmp eq i64 [[TMP12]], [[TMP13]]
30+
; CHECK-NEXT: br label [[L90]]
31+
; CHECK: L90:
32+
; CHECK-NEXT: [[VALUE_PHI2_OFF0:%.*]] = phi i1 [ false, [[TOP:%.*]] ], [ [[DOTNOT19]], [[L74]] ], [ false, [[L70]] ]
33+
; CHECK-NEXT: ret void
34+
;
35+
top:
36+
%2 = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* %0, i64 0, i64 1, i64 2
37+
%3 = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* %0, i64 0, i64 1, i64 3
38+
%4 = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* %0, i64 0, i64 1, i64 4
39+
%5 = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* %1, i64 0, i64 1, i64 2
40+
%6 = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* %1, i64 0, i64 1, i64 3
41+
%7 = getelementptr inbounds [2 x [5 x i64]], [2 x [5 x i64]] addrspace(11)* %1, i64 0, i64 1, i64 4
42+
%8 = load i64, i64 addrspace(11)* %2, align 8
43+
%9 = load i64, i64 addrspace(11)* %5, align 8
44+
%.not17 = icmp eq i64 %8, %9
45+
br i1 %.not17, label %L70, label %L90
46+
47+
L70: ; preds = %top
48+
%10 = load i64, i64 addrspace(11)* %3, align 8
49+
%11 = load i64, i64 addrspace(11)* %6, align 8
50+
%.not18 = icmp eq i64 %10, %11
51+
br i1 %.not18, label %L74, label %L90
52+
53+
L74: ; preds = %L70
54+
%12 = load i64, i64 addrspace(11)* %4, align 8
55+
%13 = load i64, i64 addrspace(11)* %7, align 8
56+
%.not19 = icmp eq i64 %12, %13
57+
br label %L90
58+
59+
L90: ; preds = %L74, %L70, %top
60+
%value_phi2.off0 = phi i1 [ false, %top ], [ %.not19, %L74 ], [ false, %L70 ]
61+
ret void
62+
}
63+
64+
!llvm.module.flags = !{!0}
65+
66+
!0 = !{i32 1, !"Debug Info Version", i32 3}
67+

0 commit comments

Comments
 (0)