]> granicus.if.org Git - llvm/commit
Recommit r315288: [SCCP] Propagate integer range info for parameters in IPSCCP.
authorFlorian Hahn <florian.hahn@arm.com>
Mon, 30 Oct 2017 09:04:18 +0000 (09:04 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Mon, 30 Oct 2017 09:04:18 +0000 (09:04 +0000)
commit25cc51808900c239831d6ff6a2ce663d5e0f9cd3
treef9132934d22d8471ee0ed644e49e483b7076933a
parente78fad81ecb318619aabe6639e4ab54d11c1fc9e
Recommit r315288: [SCCP] Propagate integer range info for parameters in IPSCCP.

This version of the patch includes a fix addressing a stage2 LTO buildbot
failure and addressed some additional nits.

Original commit message:
This updates the SCCP solver to use of the ValueElement lattice for
parameters, which provides integer range information. The range
information is used to remove unneeded icmp instructions.

For the following function, f() can be optimized to ret i32 2 with
this change

    source_filename = "sccp.c"
    target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
    target triple = "x86_64-unknown-linux-gnu"

    ; Function Attrs: norecurse nounwind readnone uwtable
    define i32 @main() local_unnamed_addr #0 {
    entry:
      %call = tail call fastcc i32 @f(i32 1)
      %call1 = tail call fastcc i32 @f(i32 47)
      %add3 = add nsw i32 %call, %call1
      ret i32 %add3
    }

    ; Function Attrs: noinline norecurse nounwind readnone uwtable
    define internal fastcc i32 @f(i32 %x) unnamed_addr #1 {
    entry:
      %c1 = icmp sle i32 %x, 100

      %cmp = icmp sgt i32 %x, 300
      %. = select i1 %cmp, i32 1, i32 2
      ret i32 %.
    }

    attributes #1 = { noinline }

Reviewers: davide, sanjoy, efriedma, dberlin

Reviewed By: davide, dberlin

Subscribers: mcrosier, gberry, mssimpso, dberlin, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316887 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SCCP.cpp
test/Transforms/SCCP/ip-constan-ranges.ll [new file with mode: 0644]