Skip to content

Commit 8d76c39

Browse files
committed
!fixup address latest comments, thanks
1 parent da60ef5 commit 8d76c39

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

llvm/docs/LangRef.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2929,7 +2929,7 @@ the behavior is undefined, unless one of the following exceptions applies:
29292929
must be a null pointer, otherwise the behavior is undefined.
29302930

29312931
* ``dereferenceable(<n>)`` operand bundles only guarantee the pointer is
2932-
dereferenceable at the point of the assumption and may not be
2932+
dereferenceable at the point of the assumption. The pointer may not be
29332933
dereferenceable at later pointers, e.g. because it could have been
29342934
freed.
29352935

llvm/test/Transforms/LICM/hoist-speculatable-load.ll

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,58 @@ if.end: ; preds = %for.body
110110
exit: ; preds = %if.end, %entry
111111
ret void
112112
}
113+
114+
define void @f_without_ptrtoint_and_with_nofree_nosync(ptr %ptr, ptr %ptr2, i1 %cond) nofree nosync {
115+
; CHECK-LABEL: @f_without_ptrtoint_and_with_nofree_nosync(
116+
; CHECK-NEXT: entry:
117+
; CHECK-NEXT: call void @llvm.assume(i1 true) [ "align"(ptr [[PTR:%.*]], i32 16), "dereferenceable"(ptr [[PTR]], i32 16) ]
118+
; CHECK-NEXT: br i1 [[COND:%.*]], label [[FOR_BODY_LR_PH:%.*]], label [[IF0:%.*]]
119+
; CHECK: if0:
120+
; CHECK-NEXT: store i32 0, ptr [[PTR2:%.*]], align 4
121+
; CHECK-NEXT: br label [[FOR_BODY_LR_PH]]
122+
; CHECK: for.body.lr.ph:
123+
; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[PTR]], align 4
124+
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
125+
; CHECK: for.body:
126+
; CHECK-NEXT: [[I_08:%.*]] = phi i32 [ 0, [[FOR_BODY_LR_PH]] ], [ [[INC:%.*]], [[IF_END:%.*]] ]
127+
; CHECK-NEXT: br i1 [[COND]], label [[IF_END]], label [[IF:%.*]]
128+
; CHECK: if:
129+
; CHECK-NEXT: store i32 [[TMP0]], ptr [[PTR2]], align 4
130+
; CHECK-NEXT: br label [[IF_END]]
131+
; CHECK: if.end:
132+
; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_08]], 1
133+
; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[INC]], 2
134+
; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[EXIT:%.*]]
135+
; CHECK: exit:
136+
; CHECK-NEXT: ret void
137+
;
138+
entry:
139+
call void @llvm.assume(i1 true) [ "align"(ptr %ptr, i32 16), "dereferenceable"(ptr %ptr, i32 16) ]
140+
br i1 %cond, label %for.body.lr.ph, label %if0
141+
142+
if0:
143+
store i32 0, ptr %ptr2, align 4
144+
br label %for.body.lr.ph
145+
146+
for.body.lr.ph: ; preds = %entry
147+
br label %for.body
148+
149+
for.body: ; preds = %for.body.lr.ph, %if.end
150+
%i.08 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %if.end ]
151+
br i1 %cond, label %if.end, label %if
152+
153+
if:
154+
%0 = load i32, ptr %ptr, align 4, !invariant.load !{}
155+
store i32 %0, ptr %ptr2, align 4
156+
br label %if.end
157+
158+
if.end: ; preds = %for.body
159+
%inc = add nuw nsw i32 %i.08, 1
160+
%cmp = icmp slt i32 %inc, 2
161+
br i1 %cmp, label %for.body, label %exit
162+
163+
exit: ; preds = %if.end, %entry
164+
ret void
165+
}
166+
113167
declare void @llvm.assume(i1 noundef)

0 commit comments

Comments
 (0)