1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s
3; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s
4; RUN: llc -verify-machineinstrs < %s -mtriple=powerpc64-ibm-aix-xcoff | FileCheck %s
5
6define i64 @ori_test_1(i64 %a) {
7; CHECK-LABEL: ori_test_1:
8; CHECK:       # %bb.0: # %entry
9; CHECK-NEXT:    li 3, -1
10; CHECK-NEXT:    blr
11entry:
12  %or = or i64 %a, 18446744073709551615 ; 0xffffffffffffffff
13  ret i64 %or
14}
15
16define i64 @ori_test_2(i64 %a) {
17; CHECK-LABEL: ori_test_2:
18; CHECK:       # %bb.0: # %entry
19; CHECK-NEXT:    li 4, -1
20; CHECK-NEXT:    rldimi 3, 4, 29, 15
21; CHECK-NEXT:    blr
22entry:
23  %or = or i64 %a, 562949416550400 ; 0x1ffffe0000000
24  ret i64 %or
25}
26
27define i64 @ori_test_3(i64 %a) {
28; CHECK-LABEL: ori_test_3:
29; CHECK:       # %bb.0: # %entry
30; CHECK-NEXT:    li 4, -1
31; CHECK-NEXT:    rldimi 3, 4, 3, 28
32; CHECK-NEXT:    blr
33entry:
34  %or = or i64 %a, 68719476728 ; 0xffffffff8
35  ret i64 %or
36}
37
38define i64 @ori_test_4(i64 %a) {
39; CHECK-LABEL: ori_test_4:
40; CHECK:       # %bb.0: # %entry
41; CHECK-NEXT:    lis 4, -32640
42; CHECK-NEXT:    ori 4, 4, 32903
43; CHECK-NEXT:    rldicl 4, 4, 13, 19
44; CHECK-NEXT:    or 3, 3, 4
45; CHECK-NEXT:    blr
46entry:
47  %or = or i64 %a, 17661175070719 ; 0x10101010ffff
48  ret i64 %or
49}
50
51; Don't exploit rldimi if operand has multiple uses
52define i64 @test_test_5(i64 %a, i64 %b) {
53; CHECK-LABEL: test_test_5:
54; CHECK:       # %bb.0: # %entry
55; CHECK-NEXT:    li 5, 1
56; CHECK-NEXT:    rldic 5, 5, 32, 31
57; CHECK-NEXT:    or 5, 3, 5
58; CHECK-NEXT:    add 4, 5, 4
59; CHECK-NEXT:    sub 3, 3, 4
60; CHECK-NEXT:    blr
61entry:
62  %or = or i64 %a, 4294967296
63  %add = add i64 %or, %b
64  %div = sub i64 %a, %add
65  ret i64 %div
66}
67