1; RUN: llc -O2 -march=hexagon < %s | FileCheck %s
2
3; CHECK-DAG: extractu(r{{[0-9]*}}, #3, #4)
4; CHECK-DAG: extractu(r{{[0-9]*}}, #8, #7)
5; CHECK-DAG: extractu(r{{[0-9]*}}, #8, #16)
6
7; C source:
8; typedef struct {
9;   unsigned x1:3;
10;   unsigned x2:7;
11;   unsigned x3:8;
12;   unsigned x4:12;
13;   unsigned x5:2;
14; } structx_t;
15;
16; typedef struct {
17;   unsigned y1:4;
18;   unsigned y2:3;
19;   unsigned y3:9;
20;   unsigned y4:8;
21;   unsigned y5:8;
22; } structy_t;
23;
24; void foo(structx_t *px, structy_t *py) {
25;   px->x1 = py->y1;
26;   px->x2 = py->y2;
27;   px->x3 = py->y3;
28;   px->x4 = py->y4;
29;   px->x5 = py->y5;
30; }
31
32target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-v64:64:64-v32:32:32-a0:0-n16:32"
33target triple = "hexagon"
34
35%struct.structx_t = type { i8, i8, i8, i8 }
36%struct.structy_t = type { i8, i8, i8, i8 }
37
38define void @foo(%struct.structx_t* nocapture %px, %struct.structy_t* nocapture %py) nounwind {
39entry:
40  %0 = bitcast %struct.structy_t* %py to i32*
41  %1 = load i32, i32* %0, align 4
42  %bf.value = and i32 %1, 7
43  %2 = bitcast %struct.structx_t* %px to i32*
44  %3 = load i32, i32* %2, align 4
45  %4 = and i32 %3, -8
46  %5 = or i32 %4, %bf.value
47  store i32 %5, i32* %2, align 4
48  %6 = load i32, i32* %0, align 4
49  %7 = lshr i32 %6, 4
50  %bf.clear1 = shl nuw nsw i32 %7, 3
51  %8 = and i32 %bf.clear1, 56
52  %9 = and i32 %5, -1017
53  %10 = or i32 %8, %9
54  store i32 %10, i32* %2, align 4
55  %11 = load i32, i32* %0, align 4
56  %12 = lshr i32 %11, 7
57  %bf.value4 = shl i32 %12, 10
58  %13 = and i32 %bf.value4, 261120
59  %14 = and i32 %10, -262081
60  %15 = or i32 %14, %13
61  store i32 %15, i32* %2, align 4
62  %16 = load i32, i32* %0, align 4
63  %17 = lshr i32 %16, 16
64  %bf.clear5 = shl i32 %17, 18
65  %18 = and i32 %bf.clear5, 66846720
66  %19 = and i32 %15, -1073480641
67  %20 = or i32 %19, %18
68  store i32 %20, i32* %2, align 4
69  %21 = load i32, i32* %0, align 4
70  %22 = lshr i32 %21, 24
71  %23 = shl i32 %22, 30
72  %24 = and i32 %20, 67107903
73  %25 = or i32 %24, %23
74  store i32 %25, i32* %2, align 4
75  ret void
76}
77