File: neg-imm.ll

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (46 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
; RUN: llc -mtriple=aarch64-linux-gnu -verify-machineinstrs -disable-block-placement -o - %s | FileCheck %s
; LSR used to pick a sub-optimal solution due to the target responding
; conservatively to isLegalAddImmediate for negative values.

declare void @foo(i32)

define void @test(i32 %px) {
; CHECK_LABEL: test:
; CHECK_LABEL: %entry
; CHECK: subs [[REG0:w[0-9]+]],
; CHECK: csel {{w[0-9]+}}, wzr, [[REG0]]
entry:
  %sub = add nsw i32 %px, -1
  %cmp = icmp slt i32 %px, 1
  %.sub = select i1 %cmp, i32 0, i32 %sub
  br label %for.body

for.body:
; CHECK_LABEL: %for.body
; CHECK:  cmp
; CHECK-NEXT:  b.eq
; CHECK-LABEL:  %if.then3
  %x.015 = phi i32 [ %inc, %for.inc ], [ %.sub, %entry ]
  %cmp2 = icmp eq i32 %x.015, %px
  br i1 %cmp2, label %for.inc, label %if.then3

if.then3:
  tail call void @foo(i32 %x.015)
  br label %for.inc

for.inc:
; CHECK_LABEL: %for.inc
; CHECK:  cmp
; CHECK-NEXT:  add
; CHECK-NEXT:  b.le
; CHECK_LABEL: %for.cond.cleanup
  %inc = add nsw i32 %x.015, 1
  %cmp1 = icmp sgt i32 %x.015, %px
  br i1 %cmp1, label %for.cond.cleanup.loopexit, label %for.body

for.cond.cleanup.loopexit:
  br label %for.cond.cleanup

for.cond.cleanup:
  ret void
}