[PATCH] D69571: [ValueTracking] Allow context-sensitive nullness check for non-pointers

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 8 14:42:59 PST 2019


nikic added a comment.

For reference, here's the IR reproducer based on the provided C code:

  define zeroext i8 @test(i8* nocapture readonly %0) local_unnamed_addr #0 {
    br label %2
  
  2:                                                ; preds = %5, %1
    %.06 = phi i8 [ 0, %1 ], [ %11, %5 ]
    %.0 = phi i32 [ 0, %1 ], [ 1, %5 ]
    %3 = icmp eq i32 %.0, 0
    br i1 %3, label %5, label %4
  
  4:                                                ; preds = %2
    ret i8 %.06
  
  5:                                                ; preds = %2
    %6 = load i8, i8* %0, align 1
    %7 = zext i8 %6 to i32
    %8 = shl nuw nsw i32 %.0, 3
    %9 = shl nuw nsw i32 %7, %8
    %10 = trunc i32 %9 to i8
    %11 = or i8 %.06, %10
    %12 = add nuw nsw i32 %.0, 1
    br label %2
  }

The `ret` gets optimized to `ret i8 0` with this patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69571/new/

https://reviews.llvm.org/D69571





More information about the llvm-commits mailing list