llvm.org GIT mirror llvm / c2bbf69
------------------------------------------------------------------------ r142058 | atrick | 2011-10-14 23:19:55 -0700 (Fri, 14 Oct 2011) | 7 lines Fix SCEVExpander assert during LSR: "argument of incompatible type". Just because we're dealing with a GEP doesn't mean we can assert the SCEV has a pointer type. The fix is simply to ignore the SCEV pointer type, which we really didn't need. Fixes PR11138 webkit crash. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_30@142094 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
3 changed file(s) with 33 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
236236
237237 bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L);
238238
239 bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L,
240 Type *ExpandTy);
239 bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L);
241240
242241 Value *expandAddRecExprLiterally(const SCEVAddRecExpr *);
243242 PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized,
880880 /// should match any patterns generated by getAddRecExprPHILiterally and
881881 /// expandAddtoGEP.
882882 bool SCEVExpander::isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV,
883 const Loop *L, Type *ExpandTy) {
883 const Loop *L) {
884884 switch (IncV->getOpcode()) {
885885 // Check for a simple Add/Sub or GEP of a loop invariant step.
886886 case Instruction::Add:
903903 // i1* is used by the expander to represent an address-size element.
904904 if (IncV->getNumOperands() != 2)
905905 return false;
906 unsigned AS = cast(ExpandTy)->getAddressSpace();
906 unsigned AS = cast(IncV->getType())->getAddressSpace();
907907 if (IncV->getType() != Type::getInt1PtrTy(SE.getContext(), AS)
908908 && IncV->getType() != Type::getInt8PtrTy(SE.getContext(), AS))
909909 return false;
953953 cast(PN->getIncomingValueForBlock(LatchBlock));
954954
955955 if (LSRMode) {
956 if (!isExpandedAddRecExprPHI(PN, IncV, L, ExpandTy))
956 if (!isExpandedAddRecExprPHI(PN, IncV, L))
957957 continue;
958958 }
959959 else {
15461546 cast(Phi->getIncomingValueForBlock(LatchBlock));
15471547
15481548 // If this phi is more canonical, swap it with the original.
1549 if (!isExpandedAddRecExprPHI(OrigPhiRef, OrigInc, L,
1550 OrigPhiRef->getType())
1551 && isExpandedAddRecExprPHI(Phi, IsomorphicInc, L, Phi->getType())) {
1549 if (!isExpandedAddRecExprPHI(OrigPhiRef, OrigInc, L)
1550 && isExpandedAddRecExprPHI(Phi, IsomorphicInc, L)) {
15521551 std::swap(OrigPhiRef, Phi);
15531552 std::swap(OrigInc, IsomorphicInc);
15541553 }
0 ; RUN: opt -loop-reduce -S < %s | FileCheck %s
1 ;
2 ; Test SCEVExpander reusing a phi->gep->phi IV when SCEV "wrongly"
3 ; reports the expression as an IntegerTy.
4
5 target triple = "x86_64-apple-darwin"
6
7 ; CHECK: @test
8 ; CHECK: phi
9 ; CHECK-NOT: phi
10 define void @test(i32 %rowStride) ssp align 2 {
11 entry:
12 %cond = select i1 undef, i32 %rowStride, i32 4
13 br label %for.end
14
15 for.end.critedge: ; preds = %for.end
16 br label %for.end
17
18 for.end: ; preds = %for.end.critedge, %entry
19 br i1 undef, label %for.body83, label %for.end.critedge
20
21 for.body83: ; preds = %for.body83, %for.end
22 %ptr.0157 = phi i8* [ %add.ptr96, %for.body83 ], [ null, %for.end ]
23 store i8 undef, i8* %ptr.0157, align 1
24 %add.ptr96 = getelementptr inbounds i8* %ptr.0157, i32 %cond
25 br label %for.body83
26 }