Test Failure: Transforms/LoopVectorize/partial-lcssa.ll

Test source: git

Comments: Bug in IR semantics or optimization: escapes noescape pointer

Log:

Source: <stdin>
-- 1. ModuleToFunctionPassAdaptor
-- 1. PassManager<Function> : Skipping NOP
-- 2. LoopVectorizePass

----------------------------------------
define i64 @foo(ptr nocapture %A, ptr nocapture %B, i64 %n, i64 %m, ptr %O1, ptr %O2) {
entry:
  %cmp = icmp sgt i64 %n, 0
  br i1 %cmp, label %for.body.outer.preheader, label %for.end.outer

for.body.outer.preheader:
  br label %for.body.outer

for.body.outer:
  %indvars.outer = phi i64 [ %indvars.outer.next, %for.end.inner ], [ 0, %for.body.outer.preheader ]
  %cmp2 = icmp sgt i64 %m, 0
  br i1 %cmp2, label %for.body.inner.preheader, label %for.end.inner

for.body.inner.preheader:
  br label %for.body.inner

for.body.inner:
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.inner ], [ 0, %for.body.inner.preheader ]
  %arrayidx = gep inbounds ptr nocapture %A, 4 x i64 %indvars.iv
  %v = load i32, ptr %arrayidx, align 4
  %arrayidx2 = gep inbounds ptr nocapture %B, 4 x i64 %indvars.iv
  store i32 %v, ptr %arrayidx2, align 4
  %indvars.iv.next = add i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv, %n
  br i1 %exitcond, label %for.end.inner.loopexit, label %for.body.inner

for.end.inner.loopexit:
  store i64 %indvars.iv, ptr %O1, align 4
  br label %for.end.inner

for.end.inner:
  %indvars.outer.next = add i64 %indvars.outer, 1
  %exitcond.outer = icmp eq i64 %indvars.outer, %m
  br i1 %exitcond.outer, label %for.end.outer.loopexit, label %for.body.outer

for.end.outer.loopexit:
  store i64 %indvars.outer, ptr %O2, align 4
  br label %for.end.outer

for.end.outer:
  ret i64 undef
}
Transformation seems to be correct! (syntactically equal)

-- 3. LoopVectorizePass

----------------------------------------
define i64 @foo(ptr nocapture %A, ptr nocapture %B, i64 %n, i64 %m, ptr %O1, ptr %O2) {
entry:
  %cmp = icmp sgt i64 %n, 0
  br i1 %cmp, label %for.body.outer.preheader, label %for.end.outer

for.body.outer.preheader:
  br label %for.body.outer

for.body.outer:
  %indvars.outer = phi i64 [ %indvars.outer.next, %for.end.inner ], [ 0, %for.body.outer.preheader ]
  %cmp2 = icmp sgt i64 %m, 0
  br i1 %cmp2, label %for.body.inner.preheader, label %for.end.inner

for.body.inner.preheader:
  br label %for.body.inner

for.body.inner:
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.inner ], [ 0, %for.body.inner.preheader ]
  %arrayidx = gep inbounds ptr nocapture %A, 4 x i64 %indvars.iv
  %v = load i32, ptr %arrayidx, align 4
  %arrayidx2 = gep inbounds ptr nocapture %B, 4 x i64 %indvars.iv
  store i32 %v, ptr %arrayidx2, align 4
  %indvars.iv.next = add i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv, %n
  br i1 %exitcond, label %for.end.inner.loopexit, label %for.body.inner

for.end.inner.loopexit:
  store i64 %indvars.iv, ptr %O1, align 4
  br label %for.end.inner

for.end.inner:
  %indvars.outer.next = add i64 %indvars.outer, 1
  %exitcond.outer = icmp eq i64 %indvars.outer, %m
  br i1 %exitcond.outer, label %for.end.outer.loopexit, label %for.body.outer

for.end.outer.loopexit:
  store i64 %indvars.outer, ptr %O2, align 4
  br label %for.end.outer

for.end.outer:
  ret i64 undef
}
=>
define i64 @foo(ptr nocapture %A, ptr nocapture %B, i64 %n, i64 %m, ptr %O1, ptr %O2) {
entry:
  %A2 = ptrtoint ptr nocapture %A to i64
  %B1 = ptrtoint ptr nocapture %B to i64
  %cmp = icmp sgt i64 %n, 0
  br i1 %cmp, label %for.body.outer.preheader, label %for.end.outer

for.body.outer.preheader:
  %#0 = sub i64 %B1, %A2
  %#1 = add i64 %n, 1
  br label %for.body.outer

for.body.outer:
  %indvars.outer = phi i64 [ %indvars.outer.next, %for.end.inner ], [ 0, %for.body.outer.preheader ]
  %cmp2 = icmp sgt i64 %m, 0
  br i1 %cmp2, label %for.body.inner.preheader, label %for.end.inner

for.body.inner.preheader:
  %min.iters.check = icmp ult i64 %#1, 4
  br i1 %min.iters.check, label %scalar.ph, label %vector.memcheck

vector.memcheck:
  %diff.check = icmp ult i64 %#0, 16
  br i1 %diff.check, label %scalar.ph, label %vector.ph

vector.ph:
  %n.mod.vf = urem i64 %#1, 4
  %n.vec = sub i64 %#1, %n.mod.vf
  br label %vector.body

vector.body:
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %#2 = add i64 %index, 0
  %#3 = gep inbounds ptr nocapture %A, 4 x i64 %#2
  %#4 = gep inbounds ptr %#3, 4 x i32 0
  %wide.load = load <4 x i32>, ptr %#4, align 4
  %#5 = gep inbounds ptr nocapture %B, 4 x i64 %#2
  %#6 = gep inbounds ptr %#5, 4 x i32 0
  store <4 x i32> %wide.load, ptr %#6, align 4
  %index.next = add nuw i64 %index, 4
  %#7 = icmp eq i64 %index.next, %n.vec
  br i1 %#7, label %middle.block, label %vector.body

middle.block:
  %cmp.n = icmp eq i64 %#1, %n.vec
  %ind.escape = sub i64 %n.vec, 1
  br i1 %cmp.n, label %for.end.inner.loopexit, label %scalar.ph

scalar.ph:
  %bc.resume.val = phi i64 [ %n.vec, %middle.block ], [ 0, %for.body.inner.preheader ], [ 0, %vector.memcheck ]
  br label %for.body.inner

for.body.inner:
  %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.inner ], [ %bc.resume.val, %scalar.ph ]
  %arrayidx = gep inbounds ptr nocapture %A, 4 x i64 %indvars.iv
  %v = load i32, ptr %arrayidx, align 4
  %arrayidx2 = gep inbounds ptr nocapture %B, 4 x i64 %indvars.iv
  store i32 %v, ptr %arrayidx2, align 4
  %indvars.iv.next = add i64 %indvars.iv, 1
  %exitcond = icmp eq i64 %indvars.iv, %n
  br i1 %exitcond, label %for.end.inner.loopexit, label %for.body.inner

for.end.inner.loopexit:
  %indvars.iv.lcssa = phi i64 [ %indvars.iv, %for.body.inner ], [ %ind.escape, %middle.block ]
  store i64 %indvars.iv.lcssa, ptr %O1, align 4
  br label %for.end.inner

for.end.inner:
  %indvars.outer.next = add i64 %indvars.outer, 1
  %exitcond.outer = icmp eq i64 %indvars.outer, %m
  br i1 %exitcond.outer, label %for.end.outer.loopexit, label %for.body.outer

for.end.outer.loopexit:
  store i64 %indvars.outer, ptr %O2, align 4
  br label %for.end.outer

for.end.outer:
  ret i64 undef
}
Transformation doesn't verify! (unsound)
ERROR: Source is more defined than target

Example:
ptr nocapture %A = poison
ptr nocapture %B = poison
i64 %n = #x0000000000000000 (0)
i64 %m = poison
ptr %O1 = poison
ptr %O2 = poison

Source:
i1 %cmp = #x0 (0)
  >> Jump to %for.end.outer

SOURCE MEMORY STATE
===================
NON-LOCAL BLOCKS:
Block 0 >	size: 0	align: 4	alloc type: 0	alive: false	address: 0
Block 1 >	size: 0	align: 1	alloc type: 0	alive: true	address: 8
Block 2 >	size: 0	align: 2	alloc type: 0	alive: true	address: 6
Block 3 >	size: 0	align: 1	alloc type: 0	alive: true	address: 6
Block 4 >	size: 0	align: 1	alloc type: 0	alive: true	address: 7

Target:
i64 %A2 = UB triggered!


Pass: LoopVectorizePass
Command line: '/home/nlopes/llvm/build/bin/opt' '-load=/home/nlopes/alive2/build/tv/tv.so' '-load-pass-plugin=/home/nlopes/alive2/build/tv/tv.so' '-tv-exit-on-error' '-passes=loop-vectorize' '-force-vector-interleave=1' '-force-vector-width=4' '-S' '-tv-smt-to=20000' '-tv-report-dir=/home/nlopes/alive2/build/logs' '-tv-smt-stats'
Wrote bitcode to: "/home/nlopes/alive2/build/logs/in_x5PpVuOe_2VL3.bc"


------------------- SMT STATS -------------------
Num queries: 46
Num invalid: 0
Num skips:   0
Num trivial: 2 (4.2%)
Num timeout: 0 (0.0%)
Num errors:  0 (0.0%)
Num SAT:     40 (87.0%)
Num UNSAT:   6 (13.0%)
Alive2: Transform doesn't verify; aborting!

stderr:

RUN: at line 1: /home/nlopes/alive2/build/opt-alive.sh < /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/partial-lcssa.ll -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -S | /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/partial-lcssa.ll
+ /home/nlopes/alive2/build/opt-alive.sh -passes=loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -S
+ /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/partial-lcssa.ll

FileCheck error: '<stdin>' is empty.
FileCheck command line:  /bitbucket/nlopes/llvm/build/bin/FileCheck /bitbucket/nlopes/llvm/llvm/test/Transforms/LoopVectorize/partial-lcssa.ll

 

<-- Back