[PATCH] D36656: [SCCP] Propagate integer range information in IPSCCP (WIP).

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 13 15:02:27 PDT 2017


fhahn created this revision.

This is a simple proof-of-concept patch that extends the SCCP solver
lattice to include range information for integer values. The range
information is propagated using assume intrinsics to called functions.

This is intended to fix PR33253 and I would appreciate any feedback on
the approach (I know the code does not cover all cases and is not too
tidy for now), i.e. should we extend the lattice to support range
information or should we use something different? Would the range
information be useful for SCCP passes other than IPSCCP? Or should we
make use of LazyValueInfo for that?

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 }


https://reviews.llvm.org/D36656

Files:
  lib/Transforms/Scalar/SCCP.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36656.110895.patch
Type: text/x-patch
Size: 9420 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170813/a9cc5dba/attachment.bin>


More information about the llvm-commits mailing list