1 ; RUN: opt < %s -loop-reduce -S | FileCheck %s
3 target datalayout = "e-i64:64-v16:16-v32:32-n16:32:64"
5 ; for (int i = 0; i < n; ++i) {
7 ; // i * a + b is ephemeral and shouldn't be promoted by LSR
8 ; __builtin_assume(i * a + b >= 0);
10 define void @ephemeral(i32 %a, i32 %b, i32 %n) {
11 ; CHECK-LABEL: @ephemeral(
16 %i = phi i32 [ 0, %entry ], [ %inc, %loop ]
17 ; Only i and i * 5 + 3 should be indvars, not i * a + b.
21 %inc = add nsw i32 %i, 1
22 %exitcond = icmp eq i32 %inc, %n
24 %0 = mul nsw i32 %i, 5
25 %1 = add nsw i32 %0, 3
26 call void @use(i32 %1)
28 %2 = mul nsw i32 %i, %a
29 %3 = add nsw i32 %2, %b
30 %4 = icmp sgt i32 %3, -1
31 call void @llvm.assume(i1 %4)
33 br i1 %exitcond, label %exit, label %loop
39 declare void @use(i32)
41 declare void @llvm.assume(i1)