1; RUN: opt %loadPolly -polly-scops -analyze < %s 2; 3; This crased at some point as we place %1 and %4 in the same equivalence class 4; for invariant loads and when we remap SCEVs to use %4 instead of %1 AddRec SCEVs 5; for the for.body.10 loop caused a crash as their operands were not invariant 6; in the loop. While we know they are, ScalarEvolution does not. However, we can simply 7; rewrite the AddRecs to hoist everything from the "start" out of the AddRec. 8; 9; Check we do not crash. 10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 11 12%struct.codebook.48.118.748.1882.2972 = type { i64, i64, i64, %struct.static_codebook.19.89.719.1853.2971*, float*, i32*, i32*, i8*, i32*, i32, i32 } 13%struct.static_codebook.19.89.719.1853.2971 = type { i64, i64, i64*, i32, i64, i64, i32, i32, i64*, %struct.encode_aux_nearestmatch.16.86.716.1850.2968*, %struct.encode_aux_threshmatch.17.87.717.1851.2969*, %struct.encode_aux_pigeonhole.18.88.718.1852.2970*, i32 } 14%struct.encode_aux_nearestmatch.16.86.716.1850.2968 = type { i64*, i64*, i64*, i64*, i64, i64 } 15%struct.encode_aux_threshmatch.17.87.717.1851.2969 = type { float*, i64*, i32, i32 } 16%struct.encode_aux_pigeonhole.18.88.718.1852.2970 = type { float, float, i32, i32, i64*, i64, i64*, i64*, i64* } 17 18; Function Attrs: inlinehint nounwind uwtable 19declare i64 @decode_packed_entry_number() #0 20 21; Function Attrs: nounwind uwtable 22define void @vorbis_book_decodev_set(%struct.codebook.48.118.748.1882.2972* %book) #1 { 23entry: 24 br i1 undef, label %for.body, label %return 25 26for.cond.loopexit: ; preds = %for.body.10, %if.end 27 br i1 undef, label %for.body, label %return 28 29for.body: ; preds = %for.cond.loopexit, %entry 30 %call = tail call i64 @decode_packed_entry_number() 31 br i1 undef, label %return, label %if.end 32 33if.end: ; preds = %for.body 34 %valuelist = getelementptr inbounds %struct.codebook.48.118.748.1882.2972, %struct.codebook.48.118.748.1882.2972* %book, i64 0, i32 4 35 %0 = load float*, float** %valuelist, align 8 36 %sext = shl i64 %call, 32 37 %conv4 = ashr exact i64 %sext, 32 38 %dim = getelementptr inbounds %struct.codebook.48.118.748.1882.2972, %struct.codebook.48.118.748.1882.2972* %book, i64 0, i32 0 39 %1 = load i64, i64* %dim, align 8 40 %mul = mul nsw i64 %1, %conv4 41 %add.ptr = getelementptr inbounds float, float* %0, i64 %mul 42 %cmp8.7 = icmp sgt i64 %1, 0 43 br i1 %cmp8.7, label %for.body.10, label %for.cond.loopexit 44 45for.body.10: ; preds = %for.body.10, %if.end 46 %indvars.iv15 = phi i64 [ %indvars.iv.next16, %for.body.10 ], [ 0, %if.end ] 47 %indvars.iv.next16 = add nuw nsw i64 %indvars.iv15, 1 48 %arrayidx = getelementptr inbounds float, float* %add.ptr, i64 %indvars.iv15 49 %2 = bitcast float* %arrayidx to i32* 50 %3 = load i32, i32* %2, align 4 51 %4 = load i64, i64* %dim, align 8 52 %cmp8 = icmp slt i64 %indvars.iv.next16, %4 53 br i1 %cmp8, label %for.body.10, label %for.cond.loopexit 54 55return: ; preds = %for.body, %for.cond.loopexit, %entry 56 ret void 57} 58