31 lines · plain
1; RUN: opt < %s -passes=licm -S | FileCheck %s2; RUN: opt -passes='require<aa>,require<target-ir>,require<scalar-evolution>,require<opt-remark-emit>,loop-mssa(licm)' < %s -S | FileCheck %s3; PR198354target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"5target triple = "x86_64-unknown-linux-gnu"6 7define i32 @f(i32 %x) {8entry:9 br label %for.body10 11for.body: ; preds = %entry, %for.body12 %storemerge4 = phi i32 [ 0, %entry ], [ %inc, %for.body ]13 %mul = mul nsw i32 %x, %x14 %add2 = add nsw i32 %mul, %x15 %mul3 = add nsw i32 %add2, %mul16 %inc = add nsw i32 %storemerge4, 117 %cmp = icmp slt i32 %inc, 10018 br i1 %cmp, label %for.body, label %for.end19 20for.end: ; preds = %for.body21 %a9.0.lcssa = phi i32 [ %mul3, %for.body ]22 ret i32 %a9.0.lcssa23}24 25; Test that there is exactly one copy of mul nsw i32 %x, %x in the exit block.26; CHECK: define i32 @f(i32 [[X:%.*]])27; CHECK: for.end:28; CHECK-NOT: mul nsw i32 [[X]], [[X]]29; CHECK: mul nsw i32 [[X]], [[X]]30; CHECK-NOT: mul nsw i32 [[X]], [[X]]31