[all-commits] [llvm/llvm-project] a86ce0: [SCCP] Use conditional info with AND/OR branch con...

Florian Hahn via All-commits all-commits at lists.llvm.org
Thu Jul 9 05:07:38 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: a86ce06fafaa051554c6a21d487fa70e998dcafe
      https://github.com/llvm/llvm-project/commit/a86ce06fafaa051554c6a21d487fa70e998dcafe
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2020-07-09 (Thu, 09 Jul 2020)

  Changed paths:
    M llvm/lib/Transforms/Scalar/SCCP.cpp
    M llvm/test/Transforms/SCCP/conditions-ranges.ll

  Log Message:
  -----------
  [SCCP] Use conditional info with AND/OR branch conditions.

Currently SCCP does not combine the information of conditions joined by
AND in the true branch or OR in the false branch.

For branches on AND, 2 copies will be inserted for the true branch, with
one being the operand of the other as in the code below. We can combine
the information using intersection. Note that for the OR case, the
copies are inserted in the false branch, where using intersection is
safe as well.

    define void @foo(i32 %a) {
    entry:
      %lt = icmp ult i32 %a, 100
      %gt = icmp ugt i32 %a, 20
      %and = and i1 %lt, %gt
    ; Has predicate info
    ; branch predicate info { TrueEdge: 1 Comparison:  %lt = icmp ult i32 %a, 100 Edge: [label %entry,label %true] }
      %a.0 = call i32 @llvm.ssa.copy.140247425954880(i32 %a)
    ; Has predicate info
    ; branch predicate info { TrueEdge: 1 Comparison:  %gt = icmp ugt i32 %a, 20 Edge: [label %entry,label %false] }
      %a.1 = call i32 @llvm.ssa.copy.140247425954880(i32 %a.0)
      br i1 %and, label %true, label %false

    true:                                             ; preds = %entry
      call void @use(i32 %a.1)
      %true.1 = icmp ne i32 %a.1, 20
      call void @use.i1(i1 %true.1)
      ret void

    false:                                            ; preds = %entry
      call void @use(i32 %a.1)
      ret void
    }

Reviewers: efriedma, davide, mssimpso, nikic

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D77808




More information about the All-commits mailing list