File: builtins-ppc-xlcompat-popcnt.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (51 lines) | stat: -rw-r--r-- 1,734 bytes parent folder | download | duplicates (7)
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
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu \
; RUN:   -mcpu=pwr8 < %s | FileCheck %s --check-prefix=CHECK-64B
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu \
; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-64B
; RUN: llc -verify-machineinstrs -mtriple=powerpc-unknown-aix \
; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-32B
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
; RUN:   -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-64B

@ui = external global i32, align 4
@ull = external global i64, align 8

define dso_local signext i32 @test_builtin_ppc_poppar4() {
; CHECK-32B-LABEL: test_builtin_ppc_poppar4:
; CHECK-32B:         popcntw 3, 3
; CHECK-32B-NEXT:    clrlwi 3, 3, 31
; CHECK-32B-NEXT:    blr
; CHECK-64B-LABEL: test_builtin_ppc_poppar4:
; CHECK-64B:         popcntw 3, 3
; CHECK-64B-NEXT:    clrlwi 3, 3, 31
; CHECK-64B-NEXT:    blr
entry:
  %0 = load i32, i32* @ui, align 4
  %1 = load i32, i32* @ui, align 4
  %2 = call i32 @llvm.ctpop.i32(i32 %1)
  %3 = and i32 %2, 1
  ret i32 %3
}

declare i32 @llvm.ctpop.i32(i32)

define dso_local signext i32 @test_builtin_ppc_poppar8() {
; CHECK-32B-LABEL: test_builtin_ppc_poppar8:
; CHECK-32B:         xor 3, 3, 4
; CHECK-32B-NEXT:    popcntw 3, 3
; CHECK-32B-NEXT:    clrlwi 3, 3, 31
; CHECK-32B-NEXT:    blr
; CHECK-64B-LABEL: test_builtin_ppc_poppar8:
; CHECK-64B:         popcntd 3, 3
; CHECK-64B-NEXT:    clrldi 3, 3, 63
; CHECK-64B-NEXT:    blr
entry:
  %0 = load i64, i64* @ull, align 8
  %1 = load i64, i64* @ull, align 8
  %2 = call i64 @llvm.ctpop.i64(i64 %1)
  %3 = and i64 %2, 1
  %cast = trunc i64 %3 to i32
  ret i32 %cast
}

declare i64 @llvm.ctpop.i64(i64)