[LLVMbugs] [Bug 22475] New: Canonicalizing load -> store to use integer type confuses LICM (II)

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 5 04:04:08 PST 2015


http://llvm.org/bugs/show_bug.cgi?id=22475

            Bug ID: 22475
           Summary: Canonicalizing load -> store to use integer type
                    confuses LICM (II)
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: michael.m.kuperstein at intel.com
                CC: chandlerc at gmail.com, hfinkel at anl.gov,
                    llvmbugs at cs.uiuc.edu
    Classification: Unclassified

This is somewhat similar to, but distinct from, PR22460.

For this code:
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc"

@in = internal unnamed_addr global i32* null, align 8
@out = internal unnamed_addr global i32* null, align 8

define i64 @bar(i32 %N) {
entry:
  br label %do.body

do.body:                                          ; preds = %l2, %entry
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %l2 ]
  %total = phi i64 [ 0, %entry ], [ %next, %l2 ]
  %c = icmp eq i32 %N, 6
  br i1 %c, label %l1, label %do.body.l2_crit_edge

do.body.l2_crit_edge:                             ; preds = %do.body
  %inval.pre = load i32** @in, align 8
  br label %l2

l1:                                               ; preds = %do.body
  %0 = load i32** @in, align 8
  store i32* %0, i32** @out, align 8
  br label %l2

l2:                                               ; preds =
%do.body.l2_crit_edge, %l1
  %inval = phi i32* [ %inval.pre, %do.body.l2_crit_edge ], [ %0, %l1 ]
  store i32* %inval , i32** @out, align 8
  %int = ptrtoint i32* %inval to i64
  %next = add i64 %total, %int
  %inc = add nsw i32 %i.0, 1
  %cmp = icmp slt i32 %inc, %N
  br i1 %cmp, label %do.body, label %do.end

do.end:                                           ; preds = %l2
  ret i64 %total
}

LICM is able to merge the two stores and sink them into the exit block.

However, if the load/store pair above was canonicalized (before the PHI was
created by GVN), and l1 is replaced with:

l1:                                               ; preds = %do.body
  %v1 = load i64* bitcast (i32** @in to i64*), align 8
  store i64 %v1, i64* bitcast (i32** @out to i64*), align 8
  %0 = inttoptr i64 %v1 to i32*  
  br label %l2

LICM fails to sink the store.

The problem is that LICM::PromoteAliasSet() requires all stores in the alias
set to have the same type - while here we have two stores with different types.
Relaxing this condition to all stores having the same size doesn't work on its
own, because LoopPromoter also relies on the "same type" assumption.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150205/81a52b0a/attachment.html>


More information about the llvm-bugs mailing list