1 ; RUN: llc -verify-machineinstrs -print-before=peephole-opt -print-after=peephole-opt -mtriple=powerpc64-unknown-linux-gnu -o /dev/null 2>&1 < %s | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -print-before=peephole-opt -print-after=peephole-opt -mtriple=powerpc64le-unknown-linux-gnu -o /dev/null 2>&1 < %s | FileCheck %s
5 define signext i32 @fn1(i32 %baz) {
6 %1 = mul nsw i32 %baz, 208
7 %2 = zext i32 %1 to i64
9 %4 = ashr exact i64 %3, 48
10 ; CHECK: RLWINM8 killed {{[^,]+}}, 0, 16, 27
14 ; CHECK: ANDI8_rec {{[^,]+}}, 65520, implicit-def $cr0
15 ; CHECK: COPY killed $cr0
17 %5 = icmp eq i64 %4, 0
18 br i1 %5, label %foo, label %bar
28 define signext i32 @fn2(i64 %a, i64 %b) {
29 ; CHECK: OR8_rec {{[^, ]+}}, {{[^, ]+}}, implicit-def $cr0
30 ; CHECK: [[CREG:[^, ]+]]:crrc = COPY killed $cr
31 ; CHECK: BCC 12, killed [[CREG]]
33 %2 = icmp sgt i64 %1, -1
34 br i1 %2, label %foo, label %bar
44 define signext i32 @fn3(i32 %a) {
45 ; CHECK: ANDI_rec killed {{[%0-9]+}}{{[^,]*}}, 10, implicit-def $cr0
46 ; CHECK: [[CREG:[^, ]+]]:crrc = COPY $cr0
47 ; CHECK: BCC 76, killed [[CREG]]
49 %2 = icmp ne i32 %1, 0
50 br i1 %2, label %foo, label %bar
59 ; This test case confirms that a record-form instruction is
60 ; generated even if the branch has a static branch hint.
63 define i64 @fn4(i64 %a, i64 %b) {
69 %add = add nsw i64 %b, %a
70 %cmp = icmp eq i64 %add, 0
71 br i1 %cmp, label %if.then, label %if.end
74 tail call void @exit(i32 signext 0) #3
81 declare void @exit(i32 signext)
83 ; Since %v1 and %v2 are zero-extended 32-bit values, %1 is also zero-extended.
84 ; In this case, we want to use OR_rec instead of OR + CMPLWI.
87 define zeroext i32 @fn5(ptr %p1, ptr %p2) {
91 %v1 = load i32, ptr %p1
92 %v2 = load i32, ptr %p2
94 %2 = icmp eq i32 %1, 0
95 br i1 %2, label %foo, label %bar
104 ; This test confirms record-form instructions are emitted for comparison
105 ; against a non-zero value.
108 define ptr @fn6(ptr readonly %p) {
119 %incdec.ptr = getelementptr inbounds i8, ptr %p, i64 -1
120 %0 = load i8, ptr %incdec.ptr
121 %cmp = icmp sgt i8 %0, -1
122 br i1 %cmp, label %out, label %if.end
125 %incdec.ptr2 = getelementptr inbounds i8, ptr %p, i64 -2
126 %1 = load i8, ptr %incdec.ptr2
127 %cmp4 = icmp sgt i8 %1, -1
128 br i1 %cmp4, label %out, label %cleanup
131 %p.addr.0 = phi ptr [ %incdec.ptr, %entry ], [ %incdec.ptr2, %if.end ]
135 %retval.0 = phi ptr [ %p.addr.0, %out ], [ null, %if.end ]