1 ; RUN: opt < %s -licm -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 define i32 @f(i32 %x) {
10 for.body: ; preds = %entry, %for.body
11 %storemerge4 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
12 %mul = mul nsw i32 %x, %x
13 %add2 = add nsw i32 %mul, %x
14 %mul3 = add nsw i32 %add2, %mul
15 %inc = add nsw i32 %storemerge4, 1
16 %cmp = icmp slt i32 %inc, 100
17 br i1 %cmp, label %for.body, label %for.end
19 for.end: ; preds = %for.body
20 %a9.0.lcssa = phi i32 [ %mul3, %for.body ]
24 ; Test that there is exactly one copy of mul nsw i32 %x, %x in the exit block.
25 ; CHECK: define i32 @f(i32 [[X:%.*]])
27 ; CHECK-NOT: mul nsw i32 [[X]], [[X]]
28 ; CHECK: mul nsw i32 [[X]], [[X]]
29 ; CHECK-NOT: mul nsw i32 [[X]], [[X]]