1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s
3
4; This is good - eliminate an op by hoisting logic.
5
6define i32 @lshr_or(i32 %x, i32 %y, i32 %z, i32* %p1, i32* %p2) {
7; CHECK-LABEL: lshr_or:
8; CHECK:       # %bb.0:
9; CHECK-NEXT:    or 3, 3, 4
10; CHECK-NEXT:    srw 3, 3, 5
11; CHECK-NEXT:    blr
12  %xt = lshr i32 %x, %z
13  %yt = lshr i32 %y, %z
14  %r = or i32 %xt, %yt
15  ret i32 %r
16}
17
18; This is questionable - hoisting doesn't eliminate anything.
19; It might result in an extra register move.
20
21define i32 @lshr_or_multiuse1(i32 %x, i32 %y, i32 %z, i32* %p1, i32* %p2) {
22; CHECK-LABEL: lshr_or_multiuse1:
23; CHECK:       # %bb.0:
24; CHECK-NEXT:    srw 7, 3, 5
25; CHECK-NEXT:    srw 3, 4, 5
26; CHECK-NEXT:    or 3, 7, 3
27; CHECK-NEXT:    stw 7, 0(6)
28; CHECK-NEXT:    blr
29  %xt = lshr i32 %x, %z
30  %yt = lshr i32 %y, %z
31  store i32 %xt, i32* %p1
32  %r = or i32 %xt, %yt
33  ret i32 %r
34}
35
36; This is questionable - hoisting doesn't eliminate anything.
37
38define i32 @lshr_multiuse2(i32 %x, i32 %y, i32 %z, i32* %p1, i32* %p2) {
39; CHECK-LABEL: lshr_multiuse2:
40; CHECK:       # %bb.0:
41; CHECK-NEXT:    srw 3, 3, 5
42; CHECK-NEXT:    srw 4, 4, 5
43; CHECK-NEXT:    or 3, 3, 4
44; CHECK-NEXT:    stw 4, 0(7)
45; CHECK-NEXT:    blr
46  %xt = lshr i32 %x, %z
47  %yt = lshr i32 %y, %z
48  store i32 %yt, i32* %p2
49  %r = or i32 %xt, %yt
50  ret i32 %r
51}
52
53; This is not profitable to hoist. We need an extra shift instruction.
54
55define i32 @lshr_multiuse3(i32 %x, i32 %y, i32 %z, i32* %p1, i32* %p2) {
56; CHECK-LABEL: lshr_multiuse3:
57; CHECK:       # %bb.0:
58; CHECK-NEXT:    srw 3, 3, 5
59; CHECK-NEXT:    srw 4, 4, 5
60; CHECK-NEXT:    stw 3, 0(6)
61; CHECK-NEXT:    or 3, 3, 4
62; CHECK-NEXT:    stw 4, 0(7)
63; CHECK-NEXT:    blr
64  %xt = lshr i32 %x, %z
65  %yt = lshr i32 %y, %z
66  store i32 %xt, i32* %p1
67  store i32 %yt, i32* %p2
68  %r = or i32 %xt, %yt
69  ret i32 %r
70}
71
72