blob: c156d3bcc087588dd3a5a0b7b3cfc21414860bc6 [file] [log] [blame]
Ehsan Amiria538b0f2016-08-03 18:17:35 +00001; RUN: llc -verify-machineinstrs -mcpu=pwr7 < %s | FileCheck %s
2; RUN: llc -verify-machineinstrs -O1 -mcpu=pwr7 < %s | FileCheck %s
Tony Jiang8e8c4442017-01-16 20:12:26 +00003; RUN: llc -verify-machineinstrs -mcpu=pwr7 -ppc-gen-isel=false < %s | FileCheck --check-prefix=CHECK-NO-ISEL %s
4; RUN: llc -verify-machineinstrs -O1 -mcpu=pwr7 -ppc-gen-isel=false < %s | FileCheck --check-prefix=CHECK-NO-ISEL %s
5
Hal Finkel6aca2372014-03-02 18:23:39 +00006target datalayout = "E-m:e-i64:64-n32:64"
7target triple = "powerpc64-unknown-linux-gnu"
8
9define zeroext i1 @testi1(i1 zeroext %b1, i1 zeroext %b2) #0 {
10entry:
11 %0 = tail call i8 asm "crand $0, $1, $2", "=^wc,^wc,^wc"(i1 %b1, i1 %b2) #0
12 %1 = and i8 %0, 1
13 %tobool3 = icmp ne i8 %1, 0
14 ret i1 %tobool3
15
16; CHECK-LABEL: @testi1
17; CHECK-DAG: andi. {{[0-9]+}}, 3, 1
18; CHECK-DAG: li [[REG1:[0-9]+]], 0
Hal Finkel7c5cb062015-04-23 18:30:38 +000019; CHECK-DAG: crmove [[REG2:[0-9]+]], 1
Hal Finkel6aca2372014-03-02 18:23:39 +000020; CHECK-DAG: andi. {{[0-9]+}}, 4, 1
21; CHECK-DAG: crand [[REG3:[0-9]+]], [[REG2]], 1
22; CHECK-DAG: li [[REG4:[0-9]+]], 1
23; CHECK: isel 3, [[REG4]], [[REG1]], [[REG3]]
Tony Jiang8e8c4442017-01-16 20:12:26 +000024; CHECK-NO-ISEL-LABEL: @testi1
25; CHECK-NO-ISEL: bclr 12, 20, 0
26; CHECK-NO-ISEL: ori 3, 5, 0
27; CHECK-NO-ISEL-NEXT: blr
Hal Finkel6aca2372014-03-02 18:23:39 +000028; CHECK: blr
29}
30
31define signext i32 @testi32(i32 signext %b1, i32 signext %b2) #0 {
32entry:
33 %0 = tail call i32 asm "crand $0, $1, $2", "=^wc,^wc,^wc"(i32 %b1, i32 %b2) #0
34 ret i32 %0
35
36; The ABI sign_extend should combine with the any_extend from the asm result,
37; and the result will be 0 or -1. This highlights the fact that only the first
38; bit is meaningful.
39; CHECK-LABEL: @testi32
40; CHECK-DAG: andi. {{[0-9]+}}, 3, 1
41; CHECK-DAG: li [[REG1:[0-9]+]], 0
Hal Finkel7c5cb062015-04-23 18:30:38 +000042; CHECK-DAG: crmove [[REG2:[0-9]+]], 1
Hal Finkel6aca2372014-03-02 18:23:39 +000043; CHECK-DAG: andi. {{[0-9]+}}, 4, 1
44; CHECK-DAG: crand [[REG3:[0-9]+]], [[REG2]], 1
45; CHECK-DAG: li [[REG4:[0-9]+]], -1
46; CHECK: isel 3, [[REG4]], [[REG1]], [[REG3]]
47; CHECK: blr
48}
49
50define zeroext i8 @testi8(i8 zeroext %b1, i8 zeroext %b2) #0 {
51entry:
52 %0 = tail call i8 asm "crand $0, $1, $2", "=^wc,^wc,^wc"(i8 %b1, i8 %b2) #0
53 ret i8 %0
54
55; CHECK-LABEL: @testi8
56; CHECK-DAG: andi. {{[0-9]+}}, 3, 1
57; CHECK-DAG: li [[REG1:[0-9]+]], 0
Hal Finkel7c5cb062015-04-23 18:30:38 +000058; CHECK-DAG: crmove [[REG2:[0-9]+]], 1
Hal Finkel6aca2372014-03-02 18:23:39 +000059; CHECK-DAG: andi. {{[0-9]+}}, 4, 1
60; CHECK-DAG: crand [[REG3:[0-9]+]], [[REG2]], 1
61; CHECK-DAG: li [[REG4:[0-9]+]], 1
62; CHECK: isel 3, [[REG4]], [[REG1]], [[REG3]]
63; CHECK: blr
64}
65
Hal Finkel0f0d2982015-10-28 19:58:02 +000066attributes #0 = { nounwind "target-features"="+crbits" }
Hal Finkel6aca2372014-03-02 18:23:39 +000067