[llvm-branch-commits] [llvm-branch] r205794 - Merging r198863:

Tom Stellard thomas.stellard at amd.com
Tue Apr 8 14:18:08 PDT 2014


Author: tstellar
Date: Tue Apr  8 16:18:07 2014
New Revision: 205794

URL: http://llvm.org/viewvc/llvm-project?rev=205794&view=rev
Log:
Merging r198863:

------------------------------------------------------------------------
r198863 | stpworld | 2014-01-09 07:26:12 -0500 (Thu, 09 Jan 2014) | 6 lines

Fixed old typo in ScalarEvolution, that caused wrong SCEVs zext operation.
Detailed description is here:
http://llvm.org/bugs/show_bug.cgi?id=18000#c16

For participation in bugfix process special thanks to David Wiberg.

------------------------------------------------------------------------

Added:
    llvm/branches/release_34/test/Analysis/ScalarEvolution/zext-signed-addrec.ll
Modified:
    llvm/branches/release_34/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/branches/release_34/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/lib/Analysis/ScalarEvolution.cpp?rev=205794&r1=205793&r2=205794&view=diff
==============================================================================
--- llvm/branches/release_34/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/branches/release_34/lib/Analysis/ScalarEvolution.cpp Tue Apr  8 16:18:07 2014
@@ -6218,7 +6218,7 @@ bool ScalarEvolution::isImpliedCond(ICmp
   // LHS' type is checked for above.
   if (getTypeSizeInBits(LHS->getType()) >
       getTypeSizeInBits(FoundLHS->getType())) {
-    if (CmpInst::isSigned(Pred)) {
+    if (CmpInst::isSigned(FoundPred)) {
       FoundLHS = getSignExtendExpr(FoundLHS, LHS->getType());
       FoundRHS = getSignExtendExpr(FoundRHS, LHS->getType());
     } else {

Added: llvm/branches/release_34/test/Analysis/ScalarEvolution/zext-signed-addrec.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_34/test/Analysis/ScalarEvolution/zext-signed-addrec.ll?rev=205794&view=auto
==============================================================================
--- llvm/branches/release_34/test/Analysis/ScalarEvolution/zext-signed-addrec.ll (added)
+++ llvm/branches/release_34/test/Analysis/ScalarEvolution/zext-signed-addrec.ll Tue Apr  8 16:18:07 2014
@@ -0,0 +1,81 @@
+; RUN: opt -loop-reduce -S < %s | FileCheck %s
+; PR18000
+
+target datalayout = "e-i64:64-f80:128-s:64-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+ at a = global i32 0, align 4
+ at b = common global i32 0, align 4
+ at e = common global i8 0, align 1
+ at d = common global i32 0, align 4
+ at c = common global i32 0, align 4
+ at .str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
+
+; Function Attrs: nounwind optsize uwtable
+; CHECK-LABEL: foo
+define i32 @foo() {
+entry:
+  %.pr = load i32* @b, align 4
+  %cmp10 = icmp slt i32 %.pr, 1
+  br i1 %cmp10, label %for.cond1.preheader.lr.ph, label %entry.for.end9_crit_edge
+
+entry.for.end9_crit_edge:                         ; preds = %entry
+  %.pre = load i32* @c, align 4
+  br label %for.end9
+
+for.cond1.preheader.lr.ph:                        ; preds = %entry
+  %0 = load i32* @a, align 4
+  %tobool = icmp eq i32 %0, 0
+  br i1 %tobool, label %for.cond1.preheader.for.cond1.preheader.split_crit_edge, label %return.loopexit.split
+
+for.cond1.preheader.for.cond1.preheader.split_crit_edge: ; preds = %for.cond1.preheader.lr.ph, %for.inc8
+  %1 = phi i32 [ %inc, %for.inc8 ], [ %.pr, %for.cond1.preheader.lr.ph ]
+  br label %if.end
+
+; CHECK-LABEL: if.end
+if.end:                                           ; preds = %if.end, %for.cond1.preheader.for.cond1.preheader.split_crit_edge
+
+; CHECK: %lsr.iv = phi i32 [ %lsr.iv.next, %if.end ], [ 258, %for.cond1.preheader.for.cond1.preheader.split_crit_edge ]
+  %indvars.iv = phi i32 [ 1, %for.cond1.preheader.for.cond1.preheader.split_crit_edge ], [ %indvars.iv.next, %if.end ]
+
+  %2 = phi i8 [ 1, %for.cond1.preheader.for.cond1.preheader.split_crit_edge ], [ %dec, %if.end ]
+  %conv7 = mul i32 %indvars.iv, 258
+  %shl = and i32 %conv7, 510
+  store i32 %shl, i32* @c, align 4
+
+; CHECK: %lsr.iv.next = add i32 %lsr.iv, -258
+  %dec = add i8 %2, -1
+
+  %cmp2 = icmp sgt i8 %dec, -1
+  %indvars.iv.next = add i32 %indvars.iv, -1
+  br i1 %cmp2, label %if.end, label %for.inc8
+
+for.inc8:                                         ; preds = %if.end
+  store i32 0, i32* @d, align 4
+  %inc = add nsw i32 %1, 1
+  store i32 %inc, i32* @b, align 4
+  %cmp = icmp slt i32 %1, 0
+  br i1 %cmp, label %for.cond1.preheader.for.cond1.preheader.split_crit_edge, label %for.cond.for.end9_crit_edge
+
+for.cond.for.end9_crit_edge:                      ; preds = %for.inc8
+  store i8 %dec, i8* @e, align 1
+  br label %for.end9
+
+for.end9:                                         ; preds = %entry.for.end9_crit_edge, %for.cond.for.end9_crit_edge
+  %3 = phi i32 [ %.pre, %entry.for.end9_crit_edge ], [ %shl, %for.cond.for.end9_crit_edge ]
+  %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %3) #2
+  br label %return
+
+return.loopexit.split:                            ; preds = %for.cond1.preheader.lr.ph
+  store i8 1, i8* @e, align 1
+  store i32 0, i32* @d, align 4
+  br label %return
+
+return:                                           ; preds = %return.loopexit.split, %for.end9
+  %retval.0 = phi i32 [ 0, %for.end9 ], [ 1, %return.loopexit.split ]
+  ret i32 %retval.0
+}
+
+; Function Attrs: nounwind optsize
+declare i32 @printf(i8* nocapture readonly, ...)
+





More information about the llvm-branch-commits mailing list