1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt < %s -S -p='newgvn' | FileCheck %s
3 ; MemorySSA should be able to handle a clobber query with an empty MemoryLocation.
5 define ptr @userread(ptr %p) {
6 ; CHECK-LABEL: define ptr @userread(
7 ; CHECK-SAME: ptr [[P:%.*]]) {
9 ; CHECK-NEXT: br label [[LOOP:%.*]]
11 ; CHECK-NEXT: [[POS:%.*]] = phi i64 [ 1, [[ENTRY:%.*]] ], [ [[DIFF:%.*]], [[LOOP]] ]
12 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[P]], i64 [[POS]]
13 ; CHECK-NEXT: [[LD:%.*]] = load ptr, ptr [[GEP]], align 8
14 ; CHECK-NEXT: [[READVAL:%.*]] = call i64 @fread(ptr noundef nonnull [[GEP]], i64 noundef 1, i64 noundef [[POS]], ptr noundef [[LD]])
15 ; CHECK-NEXT: [[READVALISPOS:%.*]] = icmp eq i64 [[READVAL]], [[POS]]
16 ; CHECK-NEXT: call void @llvm.assume(i1 [[READVALISPOS]])
17 ; CHECK-NEXT: [[DIFF]] = sub i64 0, [[POS]]
18 ; CHECK-NEXT: br label [[LOOP]]
23 loop: ; preds = %loop, %entry
24 ; 2 = MemoryPhi({entry,liveOnEntry},{loop,1})
25 %pos = phi i64 [ 1, %entry ], [ %diff, %loop ]
26 %gep = getelementptr inbounds i8, ptr %p, i64 %pos
28 %ld = load ptr, ptr %gep, align 8
30 %readval = call i64 @fread(ptr noundef nonnull %gep, i64 noundef 1, i64 noundef %pos, ptr noundef %ld)
31 %readvalispos = icmp eq i64 %readval, %pos
32 call void @llvm.assume(i1 %readvalispos)
33 %diff = sub i64 0, %pos
37 declare noundef i64 @fread(ptr nocapture noundef %0, i64 noundef %1, i64 noundef %2, ptr nocapture noundef %3) local_unnamed_addr #0
38 declare void @llvm.assume(i1 %cond)
40 attributes #0 = { nofree nounwind "frame-pointer"="non-leaf" "no-trapping-math"="true" "prefer-vector-width"="128" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+aes,+cmov,+crc32,+cx16,+cx8,+fxsr,+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "tune-cpu"="generic" }