68 lines · plain
1; RUN: opt < %s -loop-reduce -S | FileCheck %s2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"4target triple = "x86_64-apple-macosx10.9.0"5 6; LSR shouldn't normalize IV if it can't be denormalized to the original7; expression. In this testcase, the normalized expression was denormalized to8; an expression different from the original, and we were losing sign extension.9 10; CHECK: [[TMP:%[a-z]+]] = trunc i32 {{.*}} to i811; CHECK: {{%[a-z0-9]+}} = sext i8 [[TMP]] to i3212 13@j = common global i32 0, align 414@c = common global i32 0, align 415@g = common global i32 0, align 416@h = common global i8 0, align 117@d = common global i32 0, align 418@i = common global i32 0, align 419@e = common global i32 0, align 420@.str = private unnamed_addr constant [4 x i8] c"%x\0A\00", align 121@a = common global i32 0, align 422@b = common global i16 0, align 223 24; Function Attrs: nounwind optsize ssp uwtable25define i32 @main() #0 {26entry:27 store i8 0, ptr @h, align 128 %0 = load i32, ptr @j, align 429 %tobool.i = icmp eq i32 %0, 030 %1 = load i32, ptr @d, align 431 %cmp3 = icmp sgt i32 %1, -132 %.lobit = lshr i32 %1, 3133 %.lobit.not = xor i32 %.lobit, 134 br label %for.body35 36for.body: ; preds = %entry, %fn3.exit37 %inc9 = phi i8 [ 0, %entry ], [ %inc, %fn3.exit ]38 %conv = sext i8 %inc9 to i3239 br i1 %tobool.i, label %fn3.exit, label %land.rhs.i40 41land.rhs.i: ; preds = %for.body42 store i32 0, ptr @c, align 443 br label %fn3.exit44 45fn3.exit: ; preds = %for.body, %land.rhs.i46 %inc = add i8 %inc9, 147 %cmp = icmp sgt i8 %inc, -148 br i1 %cmp, label %for.body, label %for.end49 50for.end: ; preds = %fn3.exit51 %.lobit.not. = select i1 %cmp3, i32 %.lobit.not, i32 052 store i32 %conv, ptr @g, align 453 store i32 %.lobit.not., ptr @i, align 454 store i8 %inc, ptr @h, align 155 %conv7 = sext i8 %inc to i3256 %add = add nsw i32 %conv7, %conv57 store i32 %add, ptr @e, align 458 %call = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %add) #259 ret i32 060}61 62; Function Attrs: nounwind optsize63declare i32 @printf(ptr nocapture readonly, ...) #164 65attributes #0 = { nounwind optsize ssp uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }66attributes #1 = { nounwind optsize "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "use-soft-float"="false" }67attributes #2 = { nounwind optsize }68