File: hoist-xor-by-constant-from-xor-by-value.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (109 lines) | stat: -rw-r--r-- 3,590 bytes parent folder | download | duplicates (4)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=instcombine -S | FileCheck %s

declare i8 @gen8()
declare void @use8(i8)

@a = global i8 17

define i8 @t0_scalar(i8 %x, i8 %y) {
; CHECK-LABEL: @t0_scalar(
; CHECK-NEXT:    [[TMP1:%.*]] = xor i8 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[R:%.*]] = xor i8 [[TMP1]], 42
; CHECK-NEXT:    ret i8 [[R]]
;
  %i0 = xor i8 %x, 42
  %r = xor i8 %i0, %y
  ret i8 %r
}

define <2 x i8> @t1_splatvec(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: @t1_splatvec(
; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 42>
; CHECK-NEXT:    ret <2 x i8> [[R]]
;
  %i0 = xor <2 x i8> %x, <i8 42, i8 42>
  %r = xor <2 x i8> %i0, %y
  ret <2 x i8> %r
}
define <2 x i8> @t2_vec(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: @t2_vec(
; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 24>
; CHECK-NEXT:    ret <2 x i8> [[R]]
;
  %i0 = xor <2 x i8> %x, <i8 42, i8 24>
  %r = xor <2 x i8> %i0, %y
  ret <2 x i8> %r
}
define <2 x i8> @t3_vec_undef(<2 x i8> %x, <2 x i8> %y) {
; CHECK-LABEL: @t3_vec_undef(
; CHECK-NEXT:    [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT:    [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 undef>
; CHECK-NEXT:    ret <2 x i8> [[R]]
;
  %i0 = xor <2 x i8> %x, <i8 42, i8 undef>
  %r = xor <2 x i8> %i0, %y
  ret <2 x i8> %r
}

define i8 @t4_extrause(i8 %x, i8 %y) {
; CHECK-LABEL: @t4_extrause(
; CHECK-NEXT:    [[I0:%.*]] = xor i8 [[X:%.*]], 42
; CHECK-NEXT:    call void @use8(i8 [[I0]])
; CHECK-NEXT:    [[R:%.*]] = xor i8 [[I0]], [[Y:%.*]]
; CHECK-NEXT:    ret i8 [[R]]
;
  %i0 = xor i8 %x, 42
  call void @use8(i8 %i0)
  %r = xor i8 %i0, %y
  ret i8 %r
}

define i8 @t5_commutativity(i8 %x) {
; CHECK-LABEL: @t5_commutativity(
; CHECK-NEXT:    [[Y:%.*]] = call i8 @gen8()
; CHECK-NEXT:    [[TMP1:%.*]] = xor i8 [[Y]], [[X:%.*]]
; CHECK-NEXT:    [[R:%.*]] = xor i8 [[TMP1]], 42
; CHECK-NEXT:    ret i8 [[R]]
;
  %i0 = xor i8 %x, 42
  %y = call i8 @gen8()
  %r = xor i8 %y, %i0
  ret i8 %r
}

@global_constant = internal global i32 0, align 4
@global_constant2 = internal global i32 0, align 4

define i8 @constantexpr(i8 %or) local_unnamed_addr #0 {
; CHECK-LABEL: @constantexpr(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[R:%.*]] = xor i8 [[OR:%.*]], xor (i8 ptrtoint (ptr @global_constant to i8), i8 ptrtoint (ptr @global_constant2 to i8))
; CHECK-NEXT:    ret i8 [[R]]
;
entry:
  %r = xor i8 %or, xor (i8 xor (i8 ptrtoint (ptr @global_constant to i8), i8 -1), i8 xor (i8 ptrtoint (ptr @global_constant2 to i8), i8 -1))
  ret i8 %r
}

@global_constant3 = external global [6 x [1 x i64]], align 1
@global_constant4 = external global i64, align 1
@global_constant5 = external global ptr, align 1

define i16 @constantexpr2() {
; CHECK-LABEL: @constantexpr2(
; CHECK-NEXT:    [[I2:%.*]] = load ptr, ptr @global_constant5, align 1
; CHECK-NEXT:    [[I3:%.*]] = load i16, ptr [[I2]], align 1
; CHECK-NEXT:    [[I5:%.*]] = xor i16 [[I3]], xor (i16 zext (i1 icmp ne (ptr getelementptr inbounds ([6 x [1 x i64]], ptr @global_constant3, i64 0, i64 5, i64 0), ptr @global_constant4) to i16), i16 -1)
; CHECK-NEXT:    ret i16 [[I5]]
;
  %i0 = icmp ne ptr getelementptr inbounds ([6 x [1 x i64]], ptr @global_constant3, i16 0, i16 5, i16 0), @global_constant4
  %i1 = zext i1 %i0 to i16
  %i2 = load ptr, ptr @global_constant5, align 1
  %i3 = load i16, ptr %i2, align 1
  %i4 = xor i16 %i3, %i1
  %i5 = xor i16 %i4, -1
  ret i16 %i5
}