llvm.org GIT mirror llvm / a9228aa
[SCEV] Revert bailout added in r75511. Summary: With the introduction of MarkPendingLoopPredicates in r157092, I don't think the bailout is needed anymore. Reviewers: atrick, nicholas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D8624 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233296 91177308-0d34-0410-b5e6-96231b3b80d8 Sanjoy Das 5 years ago
2 changed file(s) with 56 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
67926792 ICmpInst *ICI = dyn_cast(FoundCondValue);
67936793 if (!ICI) return false;
67946794
6795 // Bail if the ICmp's operands' types are wider than the needed type
6796 // before attempting to call getSCEV on them. This avoids infinite
6797 // recursion, since the analysis of widening casts can require loop
6798 // exit condition information for overflow checking, which would
6799 // lead back here.
6800 if (getTypeSizeInBits(LHS->getType()) <
6801 getTypeSizeInBits(ICI->getOperand(0)->getType()))
6802 return false;
6803
68046795 // Now that we found a conditional branch that dominates the loop or controls
68056796 // the loop latch. Check to see if it is the comparison we are looking for.
68066797 ICmpInst::Predicate FoundPred;
68126803 const SCEV *FoundLHS = getSCEV(ICI->getOperand(0));
68136804 const SCEV *FoundRHS = getSCEV(ICI->getOperand(1));
68146805
6815 // Balance the types. The case where FoundLHS' type is wider than
6816 // LHS' type is checked for above.
6817 if (getTypeSizeInBits(LHS->getType()) >
6806 // Balance the types.
6807 if (getTypeSizeInBits(LHS->getType()) <
6808 getTypeSizeInBits(FoundLHS->getType())) {
6809 if (CmpInst::isSigned(Pred)) {
6810 LHS = getSignExtendExpr(LHS, FoundLHS->getType());
6811 RHS = getSignExtendExpr(RHS, FoundLHS->getType());
6812 } else {
6813 LHS = getZeroExtendExpr(LHS, FoundLHS->getType());
6814 RHS = getZeroExtendExpr(RHS, FoundLHS->getType());
6815 }
6816 } else if (getTypeSizeInBits(LHS->getType()) >
68186817 getTypeSizeInBits(FoundLHS->getType())) {
68196818 if (CmpInst::isSigned(FoundPred)) {
68206819 FoundLHS = getSignExtendExpr(FoundLHS, LHS->getType());
0 ; RUN: opt -S -indvars < %s | FileCheck %s
1
2 declare void @use(i1)
3
4 define void @sext_condition(i8 %t) {
5 ; CHECK-LABEL: sext_condition
6 entry:
7 %st = sext i8 %t to i16
8 %ecmp = icmp slt i16 %st, 42
9 br i1 %ecmp, label %loop, label %exit
10
11 loop:
12 ; CHECK-LABEL: loop
13 %idx = phi i8 [ %t, %entry ], [ %idx.inc, %loop ]
14 %idx.inc = add i8 %idx, 1
15 %c = icmp slt i8 %idx, 42
16 ; CHECK: call void @use(i1 true)
17 call void @use(i1 %c)
18 %be = icmp slt i8 %idx.inc, 42
19 br i1 %be, label %loop, label %exit
20
21 exit:
22 ret void
23 }
24
25 define void @zext_condition(i8 %t) {
26 ; CHECK-LABEL: zext_condition
27 entry:
28 %st = zext i8 %t to i16
29 %ecmp = icmp ult i16 %st, 42
30 br i1 %ecmp, label %loop, label %exit
31
32 loop:
33 ; CHECK-LABEL: loop
34 %idx = phi i8 [ %t, %entry ], [ %idx.inc, %loop ]
35 %idx.inc = add i8 %idx, 1
36 %c = icmp ult i8 %idx, 42
37 ; CHECK: call void @use(i1 true)
38 call void @use(i1 %c)
39 %be = icmp ult i8 %idx.inc, 42
40 br i1 %be, label %loop, label %exit
41
42 exit:
43 ret void
44 }