1 ; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -disable-block-placement -o - %s | FileCheck %s
2 ; LSR used to pick a sub-optimal solution due to the target responding
3 ; conservatively to isLegalAddImmediate for negative values.
7 define void @test(i32 %px) {
10 ; CHECK: subs [[REG0:w[0-9]+]],
11 ; CHECK: csel {{w[0-9]+}}, wzr, [[REG0]]
13 %sub = add nsw i32 %px, -1
14 %cmp = icmp slt i32 %px, 1
15 %.sub = select i1 %cmp, i32 0, i32 %sub
19 ; CHECK_LABEL: %for.body
22 ; CHECK-LABEL: %if.then3
23 %x.015 = phi i32 [ %inc, %for.inc ], [ %.sub, %entry ]
24 %cmp2 = icmp eq i32 %x.015, %px
25 br i1 %cmp2, label %for.inc, label %if.then3
28 tail call void @foo(i32 %x.015)
32 ; CHECK_LABEL: %for.inc
36 ; CHECK_LABEL: %for.cond.cleanup
37 %inc = add nsw i32 %x.015, 1
38 %cmp1 = icmp sgt i32 %x.015, %px
39 br i1 %cmp1, label %for.cond.cleanup.loopexit, label %for.body
41 for.cond.cleanup.loopexit:
42 br label %for.cond.cleanup