[PATCH] D43375: [SCEV] Prove predicates in loops via monotonicity

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 20 23:41:21 PST 2018


mkazantsev planned changes to this revision.
mkazantsev added a comment.

@apilipenko you were right. I was able to construct a test which demonstrates the problem:

  define void @test_03(i32* %p, i32* %a) {
  
  entry:
    %len = load i32, i32* %p, align 4, !range !0
    %len.minus.1 = add nsw i32 %len, -1
    %zero_check = icmp eq i32 %len, 0
    br i1 %zero_check, label %loopexit, label %preheader
  
  preheader:
    br label %loop
  
  loopexit:
    ret void
  
  loop:
    %iv = phi i32 [ %iv.next, %loop ], [ -2000000000, %preheader ]
    %iv.wide = zext i32 %iv to i64
    %el = getelementptr inbounds i32, i32* %a, i64 %iv.wide
    %fishy = icmp sgt i32 %iv, -2000000009
    call void(i1, ...) @llvm.experimental.guard(i1 %fishy) [ "deopt"() ]
    store atomic i32 0, i32* %el unordered, align 4
    %iv.next = add nsw i32 %iv, -1
    %loopcond = icmp eq i32 %iv, 2000000000
    br i1 %loopcond, label %loopexit, label %loop
  }

-indvars here produces infinite loop instead of deopt after reachng -2000000009. I need to think on alternative solution.


https://reviews.llvm.org/D43375





More information about the llvm-commits mailing list