[PATCH] D28204: [ValueTracking] use nonnull argument attribute to eliminate null checks

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 11 10:36:35 PST 2017


spatel added inline comments.


================
Comment at: test/Analysis/ValueTracking/known-nonnull-at.ll:73
+f:
+  call void @bar(i8* %x, i8* %y)
+  ret i1 %null_check
----------------
reames wrote:
> Minor: We can actually fold the null_check on this path because the call dominates the *use*.  However, you can happily ignore that.  :)
Nice catch! I think we can't do that with -instsimplify because it requires modifying the ret insts, but -gvn does the job:

$ ./opt -gvn nullch.ll -S
...
  define i1 @caller5(i8* %x, i8* %y) {
    %null_check = icmp eq i8* %y, null
    br i1 %null_check, label %t, label %f

  t:                                                ; preds = %0
    ret i1 true

  f:                                                ; preds = %0
    call void @bar(i8* %x, i8* %y)
    ret i1 false
  }



https://reviews.llvm.org/D28204





More information about the llvm-commits mailing list