85 lines · plain
1; RUN: opt -hexagon-loop-idiom -S < %s | FileCheck %s2; RUN: opt -p hexagon-loop-idiom -S < %s | FileCheck %s3; CHECK-LABEL: define void @fred4 5; Check that this test does not crash.6 7target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"8target triple = "hexagon"9 10%struct.0 = type { [120 x i16], [80 x i16], [80 x i16], [80 x i16], [80 x i16], [80 x i16], [40 x i16], [40 x i16], [40 x i16], [40 x i16], [40 x i16], [40 x i16] }11 12define void @fred(ptr %demod_state) local_unnamed_addr #0 {13entry:14 br label %for.body30915 16for.body309: ; preds = %for.body309, %entry17 %max_diff.0300 = phi i16 [ %max_diff.1, %for.body309 ], [ 0, %entry ]18 %arrayidx322.phi = phi ptr [ undef, %entry ], [ %arrayidx322.inc, %for.body309 ]19 %arrayidx331.phi = phi ptr [ undef, %entry ], [ %arrayidx331.inc, %for.body309 ]20 %lag.4299.apmt = phi i32 [ %inc376.apmt, %for.body309 ], [ 0, %entry ]21 %0 = load i16, ptr %arrayidx322.phi, align 222 %conv323 = sext i16 %0 to i3223 %sub324 = sub nsw i32 0, %conv32324 %ispos258 = icmp sgt i32 %sub324, -125 %1 = select i1 %ispos258, i32 %sub324, i32 026 %add326 = add nsw i32 %1, 027 %2 = load i16, ptr %arrayidx331.phi, align 228 %conv332 = sext i16 %2 to i3229 %sub333 = sub nsw i32 0, %conv33230 %ispos260 = icmp sgt i32 %sub333, -131 %3 = select i1 %ispos260, i32 %sub333, i32 undef32 %sub342 = sub nsw i32 0, %conv32333 %ispos262 = icmp sgt i32 %sub342, -134 %4 = select i1 %ispos262, i32 %sub342, i32 undef35 %sub351 = sub nsw i32 0, %conv33236 %ispos264 = icmp sgt i32 %sub351, -137 %5 = select i1 %ispos264, i32 %sub351, i32 038 %sub360 = sub nsw i32 %conv323, %conv33239 %ispos266 = icmp sgt i32 %sub360, -140 %6 = select i1 %ispos266, i32 %sub360, i32 041 %add335 = add nsw i32 %add326, %442 %add344 = add nsw i32 %add335, %343 %add353 = add i32 %add344, %544 %add362 = add i32 %add353, %645 %div363 = sdiv i32 %add362, 646 %conv364 = trunc i32 %div363 to i1647 %sext268 = shl i32 %div363, 1648 %conv369 = ashr exact i32 %sext268, 1649 %conv370 = sext i16 %max_diff.0300 to i3250 %cmp371 = icmp sgt i32 %conv369, %conv37051 %max_diff.1 = select i1 %cmp371, i16 %conv364, i16 %max_diff.030052 %inc376.apmt = add nuw nsw i32 %lag.4299.apmt, 153 %exitcond331 = icmp ne i32 %inc376.apmt, 4054 %arrayidx322.inc = getelementptr i16, ptr %arrayidx322.phi, i32 155 %arrayidx331.inc = getelementptr i16, ptr %arrayidx331.phi, i32 156 br i1 %exitcond331, label %for.body309, label %for.end37757 58for.end377: ; preds = %for.body30959 %max_diff.1.lcssa = phi i16 [ %max_diff.1, %for.body309 ]60 %cmp407 = icmp sgt i16 %max_diff.1.lcssa, 461 br label %for.body40562 63for.body405: ; preds = %if.end437, %for.end37764 %arrayidx412 = getelementptr inbounds %struct.0, ptr %demod_state, i32 0, i32 11, i32 undef65 br i1 %cmp407, label %if.then409, label %if.end43766 67if.then409: ; preds = %for.body40568 %arrayidx416 = getelementptr inbounds [40 x i16], ptr null, i32 0, i32 undef69 %7 = load i16, ptr %arrayidx416, align 270 %conv417 = sext i16 %7 to i3271 %shl = shl i32 %conv417, 472 %mul419 = mul nsw i32 %shl, 65573 %add420 = add nsw i32 %mul419, 074 br label %if.end43775 76if.end437: ; preds = %if.then409, %for.body40577 %mul431.sink = phi i32 [ %add420, %if.then409 ], [ undef, %for.body405 ]78 %shr432257 = lshr i32 %mul431.sink, 1579 %conv433 = trunc i32 %shr432257 to i1680 store i16 %conv433, ptr %arrayidx412, align 281 br label %for.body40582}83 84attributes #0 = { noinline nounwind "target-cpu"="hexagonv60" "target-features"="-hvx,-long-calls" }85