1 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
2 ; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr8 < %s | FileCheck %s
10 ; void bitfieldinsert64(struct s *p, unsigned short v) {
14 %struct.s64 = type { i64 }
16 define void @bitfieldinsert64(ptr nocapture %p, i16 zeroext %v) {
17 ; CHECK-LABEL: @bitfieldinsert64
18 ; CHECK: ld [[REG1:[0-9]+]], 0(3)
19 ; CHECK-NEXT: rlwimi [[REG1]], 4, 5, 11, 26
20 ; CHECK-NEXT: std [[REG1]], 0(3)
23 %0 = zext i16 %v to i64
24 %bf.load = load i64, ptr %p, align 8
25 %bf.shl = shl nuw nsw i64 %0, 5
26 %bf.clear = and i64 %bf.load, -2097121
27 %bf.set = or i64 %bf.clear, %bf.shl
28 store i64 %bf.set, ptr %p, align 8
32 ; bitfieldinsert32: Test for rlwimi
39 ; void bitfieldinsert32(struct s32 *p, unsigned int v) {
43 %struct.s32 = type { i32 }
45 define void @bitfieldinsert32(ptr nocapture %p, i32 zeroext %v) {
46 ; CHECK-LABEL: @bitfieldinsert32
47 ; CHECK: lwz [[REG1:[0-9]+]], 0(3)
48 ; CHECK-NEXT: rlwimi [[REG1]], 4, 8, 8, 23
49 ; CHECK-NEXT: stw [[REG1]], 0(3)
52 %bf.load = load i32, ptr %p, align 4
53 %bf.value = shl i32 %v, 8
54 %bf.shl = and i32 %bf.value, 16776960
55 %bf.clear = and i32 %bf.load, -16776961
56 %bf.set = or i32 %bf.clear, %bf.shl
57 store i32 %bf.set, ptr %p, align 4
61 ; test cases which include ISD::TRUNCATE
68 ; void bitfieldinsert64b(struct s64b *p, unsigned char v) {
72 %struct.s64b = type { i24, i24 }
74 define void @bitfieldinsert64b(ptr nocapture %p, i8 zeroext %v) {
75 ; CHECK-LABEL: @bitfieldinsert64b
76 ; CHECK: lwz [[REG1:[0-9]+]], 0(3)
77 ; CHECK-NEXT: rlwimi [[REG1]], 4, 4, 12, 27
78 ; CHECK-NEXT: stw [[REG1]], 0(3)
81 %conv = zext i8 %v to i32
82 %bf.load = load i32, ptr %p, align 4
83 %bf.shl = shl nuw nsw i32 %conv, 4
84 %bf.clear = and i32 %bf.load, -1048561
85 %bf.set = or i32 %bf.clear, %bf.shl
86 store i32 %bf.set, ptr %p, align 4
96 ; void bitfieldinsert64c(struct s64c *p, unsigned short v) {
100 %struct.s64c = type { i32, [4 x i8] }
102 define void @bitfieldinsert64c(ptr nocapture %p, i16 zeroext %v) {
103 ; CHECK-LABEL: @bitfieldinsert64c
104 ; CHECK: lwz [[REG1:[0-9]+]], 0(3)
105 ; CHECK-NEXT: rlwimi [[REG1]], 4, 5, 11, 26
106 ; CHECK-NEXT: stw [[REG1]], 0(3)
109 %conv = zext i16 %v to i32
110 %bf.load = load i32, ptr %p, align 8
111 %bf.shl = shl nuw nsw i32 %conv, 5
112 %bf.clear = and i32 %bf.load, -2097121
113 %bf.set = or i32 %bf.clear, %bf.shl
114 store i32 %bf.set, ptr %p, align 8