Skip to content

Commit ca5a01d

Browse files
committed
[InstSimplify] Add test for incorrect freeze of or disjoint (NFC)
1 parent 3f505cd commit ca5a01d

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

llvm/test/Transforms/InstSimplify/freeze-noundef.ll

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ define i1 @or(i1 noundef %x, i1 noundef %x2) {
2929
ret i1 %z
3030
}
3131

32+
; FIXME: This is a miscompile.
33+
define i1 @or_disjoint(i1 noundef %x, i1 noundef %x2) {
34+
; CHECK-LABEL: @or_disjoint(
35+
; CHECK-NEXT: [[Y:%.*]] = or disjoint i1 [[X:%.*]], [[X2:%.*]]
36+
; CHECK-NEXT: ret i1 [[Y]]
37+
;
38+
%y = or disjoint i1 %x, %x2
39+
%z = freeze i1 %y
40+
ret i1 %z
41+
}
42+
3243
define i1 @or2(i1 noundef %x, i1 %x2) {
3344
; CHECK-LABEL: @or2(
3445
; CHECK-NEXT: [[Y:%.*]] = or i1 [[X:%.*]], [[X2:%.*]]
@@ -61,6 +72,27 @@ define i8 @addnsw(i8 noundef %x) {
6172
ret i8 %z
6273
}
6374

75+
define i16 @zext(i8 noundef %x) {
76+
; CHECK-LABEL: @zext(
77+
; CHECK-NEXT: [[Y:%.*]] = zext i8 [[X:%.*]] to i16
78+
; CHECK-NEXT: ret i16 [[Y]]
79+
;
80+
%y = zext i8 %x to i16
81+
%z = freeze i16 %y
82+
ret i16 %z
83+
}
84+
85+
define i16 @zext_nneg(i8 noundef %x) {
86+
; CHECK-LABEL: @zext_nneg(
87+
; CHECK-NEXT: [[Y:%.*]] = zext nneg i8 [[X:%.*]] to i16
88+
; CHECK-NEXT: [[Z:%.*]] = freeze i16 [[Y]]
89+
; CHECK-NEXT: ret i16 [[Z]]
90+
;
91+
%y = zext nneg i8 %x to i16
92+
%z = freeze i16 %y
93+
ret i16 %z
94+
}
95+
6496
define {i8, i32} @aggr({i8, i32} noundef %x) {
6597
; CHECK-LABEL: @aggr(
6698
; CHECK-NEXT: ret { i8, i32 } [[X:%.*]]
@@ -107,7 +139,7 @@ define i1 @used_by_fncall(i1 %x) {
107139

108140
define i32 @noundef_metadata(ptr %p) {
109141
; CHECK-LABEL: @noundef_metadata(
110-
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef !0
142+
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[P:%.*]], align 4, !noundef [[META0:![0-9]+]]
111143
; CHECK-NEXT: ret i32 [[V]]
112144
;
113145
%v = load i32, ptr %p, !noundef !{}
@@ -117,7 +149,7 @@ define i32 @noundef_metadata(ptr %p) {
117149

118150
define {i8, i32} @noundef_metadata2(ptr %p) {
119151
; CHECK-LABEL: @noundef_metadata2(
120-
; CHECK-NEXT: [[V:%.*]] = load { i8, i32 }, ptr [[P:%.*]], align 4, !noundef !0
152+
; CHECK-NEXT: [[V:%.*]] = load { i8, i32 }, ptr [[P:%.*]], align 4, !noundef [[META0]]
121153
; CHECK-NEXT: ret { i8, i32 } [[V]]
122154
;
123155
%v = load {i8, i32}, ptr %p, !noundef !{}

0 commit comments

Comments
 (0)