[PATCH] D78133: [PredicateInfo] Add additional RenamedOp field to PB.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 14:03:57 PDT 2020


nikic added a comment.

Okay, after thinking about this a bit more, this does impact analysis quality. Here is a better test case:

  define i32 @test2(i32 %x) {
  entry:
    %cmp1 = icmp sgt i32 %x, 0
    %cmp2 = icmp sgt i32 %x, 10
    br i1 %cmp1, label %bb2, label %exit1
  
  bb2:
    br i1 %cmp2, label %exit2, label %exit3
  
  exit1:
    ret i32 0
  
  exit2:
    ret i32 %x
  
  exit3:
    ret i32 %x
  }

Gives us:

  define i32 @test2(i32 %x) {
  entry:
    %cmp1 = icmp sgt i32 %x, 0
    %cmp2 = icmp sgt i32 %x, 10
  ; Has predicate info
  ; branch predicate info { TrueEdge: 1 Comparison:  %cmp1 = icmp sgt i32 %x, 0 Edge: [label %entry,label %bb2], RenamedOp: %x }
    %x.0 = call i32 @llvm.ssa.copy.94226533345936(i32 %x)
    br i1 %cmp1, label %bb2, label %exit1
  
  bb2:                                              ; preds = %entry
  ; Has predicate info
  ; branch predicate info { TrueEdge: 1 Comparison:  %cmp2 = icmp sgt i32 %x, 10 Edge: [label %bb2,label %exit2], RenamedOp: %x }
    %x.0.1 = call i32 @llvm.ssa.copy.94226533345936(i32 %x.0)
  ; Has predicate info
  ; branch predicate info { TrueEdge: 0 Comparison:  %cmp2 = icmp sgt i32 %x, 10 Edge: [label %bb2,label %exit3], RenamedOp: %x.0 }
    %x.0.2 = call i32 @llvm.ssa.copy.94226533345936(i32 %x.0)
    br i1 %cmp2, label %exit2, label %exit3
  
  exit1:                                            ; preds = %entry
    ret i32 0
  
  exit2:                                            ; preds = %bb2
    ret i32 %x.0.1
  
  exit3:                                            ; preds = %bb2
    ret i32 %x.0.2
  }

Note that the false edge has `RenamedOp: %x.0`, but the comparison uses `%x`. That means we're going to lose the additional bound.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78133





More information about the llvm-commits mailing list