llvm.org GIT mirror llvm / 8b94db1
Fix a type mismatch assert in SCEV division An assert was triggered when attempting to create a new SCEV with operands of different types in the visitAddRecExpr. In this test case, the operand types of the numerator and denominator are different. The SCEV division code should generate a conservative answer when this happens. Differential Revision: http://reviews.llvm.org/D9021 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235511 91177308-0d34-0410-b5e6-96231b3b80d8 Brendon Cahoon 5 years ago
2 changed file(s) with 37 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
794794 assert(Numerator->isAffine() && "Numerator should be affine");
795795 divide(SE, Numerator->getStart(), Denominator, &StartQ, &StartR);
796796 divide(SE, Numerator->getStepRecurrence(SE), Denominator, &StepQ, &StepR);
797 // Bail out if the types do not match.
798 Type *Ty = Denominator->getType();
799 if (Ty != StartQ->getType() || Ty != StartR->getType() ||
800 Ty != StepQ->getType() || Ty != StepR->getType()) {
801 Quotient = Zero;
802 Remainder = Numerator;
803 return;
804 }
797805 Quotient = SE.getAddRecExpr(StartQ, StepQ, Numerator->getLoop(),
798806 Numerator->getNoWrapFlags());
799807 Remainder = SE.getAddRecExpr(StartR, StepR, Numerator->getLoop(),
0 ; RUN: opt < %s -analyze -delinearize
1 ; REQUIRES: asserts
2
3 ; Test that SCEV divide code doesn't crash when attempting to create a SCEV
4 ; with operands of different types. In this case, the visitAddRecExpr
5 ; function tries to create an AddRec where the start and step are different
6 ; types.
7
8 target datalayout = "e-m:e-p:32:32-i64:64-a:0-v32:32-n16:32"
9
10 define fastcc void @test() {
11 entry:
12 %0 = load i16, i16* undef, align 2
13 %conv21 = zext i16 %0 to i32
14 br label %for.cond7.preheader
15
16 for.cond7.preheader:
17 %p1.022 = phi i8* [ undef, %entry ], [ %add.ptr, %for.end ]
18 br label %for.body11
19
20 for.body11:
21 %arrayidx.phi = phi i8* [ %p1.022, %for.cond7.preheader ], [ undef, %for.body11 ]
22 store i8 undef, i8* %arrayidx.phi, align 1
23 br i1 undef, label %for.body11, label %for.end
24
25 for.end:
26 %add.ptr = getelementptr inbounds i8, i8* %p1.022, i32 %conv21
27 br label %for.cond7.preheader
28 }