[llvm-commits] [llvm] r102389 - in /llvm/trunk: lib/Analysis/README.txt lib/Analysis/ScalarEvolutionExpander.cpp test/CodeGen/X86/lsr-delayed-fold.ll

Dan Gohman gohman at apple.com
Mon Apr 26 14:46:36 PDT 2010


Author: djg
Date: Mon Apr 26 16:46:36 2010
New Revision: 102389

URL: http://llvm.org/viewvc/llvm-project?rev=102389&view=rev
Log:
When checking whether the special handling for an addrec increment which
doesn't dominate the header is needed, don't check whether the increment
expression has computable loop evolution. While the operands of an
addrec are required to be loop-invariant, they're not required to 
dominate any part of the loop. This fixes PR6914.

Modified:
    llvm/trunk/lib/Analysis/README.txt
    llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
    llvm/trunk/test/CodeGen/X86/lsr-delayed-fold.ll

Modified: llvm/trunk/lib/Analysis/README.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/README.txt?rev=102389&r1=102388&r2=102389&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/README.txt (original)
+++ llvm/trunk/lib/Analysis/README.txt Mon Apr 26 16:46:36 2010
@@ -17,7 +17,7 @@
 
 //===---------------------------------------------------------------------===//
 
-In test/CodeGen/X86/lsr-delayed-fold.ll,
+In formatValue in test/CodeGen/X86/lsr-delayed-fold.ll,
 
 ScalarEvolution is forming this expression:
 

Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=102389&r1=102388&r2=102389&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Mon Apr 26 16:46:36 2010
@@ -995,8 +995,7 @@
   // Strip off any non-loop-dominating component from the addrec step.
   const SCEV *Step = Normalized->getStepRecurrence(SE);
   const SCEV *PostLoopScale = 0;
-  if (!Step->hasComputableLoopEvolution(L) &&
-      !Step->dominates(L->getHeader(), SE.DT)) {
+  if (!Step->dominates(L->getHeader(), SE.DT)) {
     PostLoopScale = Step;
     Step = SE.getIntegerSCEV(1, Normalized->getType());
     Normalized =

Modified: llvm/trunk/test/CodeGen/X86/lsr-delayed-fold.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/lsr-delayed-fold.ll?rev=102389&r1=102388&r2=102389&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/lsr-delayed-fold.ll (original)
+++ llvm/trunk/test/CodeGen/X86/lsr-delayed-fold.ll Mon Apr 26 16:46:36 2010
@@ -1,8 +1,8 @@
 ; RUN: llc -march=x86-64 < %s > /dev/null
-; rdar://7886751
 
 ; ScalarEvolution misses an opportunity to fold ((trunc x) + (trunc -x) + y),
 ; but LSR should tolerate this.
+; rdar://7886751
 
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
 target triple = "x86_64-apple-darwin11.0"
@@ -26,3 +26,26 @@
 bb24:                                             ; preds = %bb21, %bb11
   unreachable
 }
+
+; ScalarEvolution should be able to correctly expand the crazy addrec here.
+; PR6914
+
+define void @int323() nounwind {
+entry:
+  br label %for.cond
+
+for.cond:                                         ; preds = %lbl_264, %for.inc, %entry
+  %g_263.tmp.1 = phi i8 [ undef, %entry ], [ %g_263.tmp.1, %for.cond ]
+  %p_95.addr.0 = phi i8 [ 0, %entry ], [ %add, %for.cond ]
+  %add = add i8 %p_95.addr.0, 1                   ; <i8> [#uses=1]
+  br i1 undef, label %for.cond, label %lbl_264
+
+lbl_264:                                          ; preds = %if.end, %lbl_264.preheader
+  %g_263.tmp.0 = phi i8 [ %g_263.tmp.1, %for.cond ] ; <i8> [#uses=1]
+  %tmp7 = load i16* undef                         ; <i16> [#uses=1]
+  %conv8 = trunc i16 %tmp7 to i8                  ; <i8> [#uses=1]
+  %mul.i = mul i8 %p_95.addr.0, %p_95.addr.0      ; <i8> [#uses=1]
+  %mul.i18 = mul i8 %mul.i, %conv8                ; <i8> [#uses=1]
+  %tobool12 = icmp eq i8 %mul.i18, 0              ; <i1> [#uses=1]
+  unreachable
+}





More information about the llvm-commits mailing list