File: vscale-intrinsic.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (81 lines) | stat: -rw-r--r-- 2,462 bytes parent folder | download | duplicates (6)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=sccp -S | FileCheck %s

define i1 @vscale_i32_noattr() {
; CHECK-LABEL: define i1 @vscale_i32_noattr() {
; CHECK-NEXT:    [[SCALE:%.*]] = call i32 @llvm.vscale.i32()
; CHECK-NEXT:    [[CMP2:%.*]] = icmp ule i32 [[SCALE]], 16
; CHECK-NEXT:    [[RES:%.*]] = and i1 true, [[CMP2]]
; CHECK-NEXT:    ret i1 [[RES]]
;
  %scale = call i32 @llvm.vscale.i32()
  %cmp1 = icmp uge i32 %scale, 1
  %cmp2 = icmp ule i32 %scale, 16
  %res = and i1 %cmp1, %cmp2
  ret i1 %res
}

define i1 @vscale_i32_attr() vscale_range(1, 16) {
; CHECK-LABEL: define i1 @vscale_i32_attr(
; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT:    [[SCALE:%.*]] = call i32 @llvm.vscale.i32()
; CHECK-NEXT:    ret i1 true
;
  %scale = call i32 @llvm.vscale.i32()
  %cmp1 = icmp uge i32 %scale, 1
  %cmp2 = icmp ule i32 %scale, 16
  %res = and i1 %cmp1, %cmp2
  ret i1 %res
}

define i1 @vscale_i64_noattr() {
; CHECK-LABEL: define i1 @vscale_i64_noattr() {
; CHECK-NEXT:    [[SCALE:%.*]] = call i64 @llvm.vscale.i64()
; CHECK-NEXT:    [[CMP2:%.*]] = icmp ule i64 [[SCALE]], 16
; CHECK-NEXT:    [[RES:%.*]] = and i1 true, [[CMP2]]
; CHECK-NEXT:    ret i1 [[RES]]
;
  %scale = call i64 @llvm.vscale.i64()
  %cmp1 = icmp uge i64 %scale, 1
  %cmp2 = icmp ule i64 %scale, 16
  %res = and i1 %cmp1, %cmp2
  ret i1 %res
}

define i1 @vscale_i64_attr() vscale_range(1, 16) {
; CHECK-LABEL: define i1 @vscale_i64_attr(
; CHECK-SAME: ) #[[ATTR0]] {
; CHECK-NEXT:    [[SCALE:%.*]] = call i64 @llvm.vscale.i64()
; CHECK-NEXT:    ret i1 true
;
  %scale = call i64 @llvm.vscale.i64()
  %cmp1 = icmp uge i64 %scale, 1
  %cmp2 = icmp ule i64 %scale, 16
  %res = and i1 %cmp1, %cmp2
  ret i1 %res
}

define i32 @vscale_branch_elim(i32 %x) vscale_range(1, 16) {
; CHECK-LABEL: define i32 @vscale_branch_elim(
; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0]] {
; CHECK-NEXT:  [[ENTRY:.*:]]
; CHECK-NEXT:    [[SCALE:%.*]] = call i32 @llvm.vscale.i32()
; CHECK-NEXT:    [[BOUND:%.*]] = shl nuw nsw i32 [[SCALE]], 3
; CHECK-NEXT:    br label %[[IF_END:.*]]
; CHECK:       [[IF_END]]:
; CHECK-NEXT:    ret i32 [[X]]
;
entry:
  %scale = call i32 @llvm.vscale.i32()
  %bound = shl nsw nuw i32 %scale, 3
  %cmp = icmp uge i32 1, %bound
  br i1 %cmp, label %if.then, label %if.end

if.then:
  %double = mul i32 %x, 2
  br label %if.end

if.end:
  %res = phi i32 [ %x, %entry ], [ %double, %if.then]
  ret i32 %res
}