File: basic.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (58 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download | duplicates (16)
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
; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll)
; RUN: opt < %s -passes=instsimplify -S | FileCheck %s

define i32 @common_sub_operand(i32 %X, i32 %Y) {
; CHECK-LABEL: @common_sub_operand(
; CHECK-NEXT:    ret i32 [[X:%.*]]
;
  %Z = sub i32 %X, %Y
  %Q = add i32 %Z, %Y
  ret i32 %Q
}

define i32 @negated_operand(i32 %x) {
; CHECK-LABEL: @negated_operand(
; CHECK-NEXT:    ret i32 0
;
  %negx = sub i32 0, %x
  %r = add i32 %negx, %x
  ret i32 %r
}

define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) {
; CHECK-LABEL: @negated_operand_commute_vec(
; CHECK-NEXT:    ret <2 x i32> zeroinitializer
;
  %negx = sub <2 x i32> zeroinitializer, %x
  %r = add <2 x i32> %x, %negx
  ret <2 x i32> %r
}

define i8 @knownnegation(i8 %x, i8 %y) {
; CHECK-LABEL: @knownnegation(
; CHECK-NEXT:    ret i8 0
;
  %xy = sub i8 %x, %y
  %yx = sub i8 %y, %x
  %r = add i8 %xy, %yx
  ret i8 %r
}

define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: @knownnegation_commute_vec(
; CHECK-NEXT:    ret <2 x i8> zeroinitializer
;
  %xy = sub <2 x i8> %x, %y
  %yx = sub <2 x i8> %y, %x
  %r = add <2 x i8> %yx, %xy
  ret <2 x i8> %r
}

define i32 @nameless_value(i32 %X) {
; CHECK-LABEL: @nameless_value(
; CHECK-NEXT:    [[TMP1:%.*]] = sub i32 42, [[X:%.*]]
; CHECK-NEXT:    ret i32 [[TMP1]]
;
  %1 = sub i32 42, %X
  ret i32 %1
}