Home | History | Annotate | Download | only in LICM
      1 ; RUN: opt < %s -licm -S | FileCheck %s
      2 ; RUN: opt -passes='require<aa>,require<targetir>,require<scalar-evolution>,loop(licm)' < %s -S | FileCheck %s
      3 ; PR19835
      4 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
      5 target triple = "x86_64-unknown-linux-gnu"
      6 
      7 define i32 @f(i32 %x) {
      8 entry:
      9   br label %for.body
     10 
     11 for.body:                                         ; preds = %entry, %for.body
     12   %storemerge4 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
     13   %mul = mul nsw i32 %x, %x
     14   %add2 = add nsw i32 %mul, %x
     15   %mul3 = add nsw i32 %add2, %mul
     16   %inc = add nsw i32 %storemerge4, 1
     17   %cmp = icmp slt i32 %inc, 100
     18   br i1 %cmp, label %for.body, label %for.end
     19 
     20 for.end:                                          ; preds = %for.body
     21   %a9.0.lcssa = phi i32 [ %mul3, %for.body ]
     22   ret i32 %a9.0.lcssa
     23 }
     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