Refactor: Simplify boolean conditional return statements in llvm/lib/Support
[oota-llvm.git] / test / CodeGen / Hexagon / insert-basic.ll
1 ; RUN: llc -O2 -march=hexagon < %s | FileCheck %s
2 ; CHECK-DAG: insert(r{{[0-9]*}}, #17, #0)
3 ; CHECK-DAG: insert(r{{[0-9]*}}, #18, #0)
4 ; CHECK-DAG: insert(r{{[0-9]*}}, #22, #0)
5 ; CHECK-DAG: insert(r{{[0-9]*}}, #12, #0)
6
7 ; C source:
8 ; typedef struct {
9 ;   unsigned x1:23;
10 ;   unsigned x2:17;
11 ;   unsigned x3:18;
12 ;   unsigned x4:22;
13 ;   unsigned x5:12;
14 ; } structx_t;
15 ;
16 ; void foo(structx_t *px, int y1, int y2, int y3, int y4, int y5) {
17 ;   px->x1 = y1;
18 ;   px->x2 = y2;
19 ;   px->x3 = y3;
20 ;   px->x4 = y4;
21 ;   px->x5 = y5;
22 ; }
23
24 target 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"
25 target triple = "hexagon"
26
27 %struct.structx_t = type { [3 x i8], i8, [3 x i8], i8, [3 x i8], i8, [3 x i8], i8, [2 x i8], [2 x i8] }
28
29 define void @foo(%struct.structx_t* nocapture %px, i32 %y1, i32 %y2, i32 %y3, i32 %y4, i32 %y5) nounwind {
30 entry:
31   %bf.value = and i32 %y1, 8388607
32   %0 = bitcast %struct.structx_t* %px to i32*
33   %1 = load i32, i32* %0, align 4
34   %2 = and i32 %1, -8388608
35   %3 = or i32 %2, %bf.value
36   store i32 %3, i32* %0, align 4
37   %bf.value1 = and i32 %y2, 131071
38   %bf.field.offs = getelementptr %struct.structx_t, %struct.structx_t* %px, i32 0, i32 0, i32 4
39   %4 = bitcast i8* %bf.field.offs to i32*
40   %5 = load i32, i32* %4, align 4
41   %6 = and i32 %5, -131072
42   %7 = or i32 %6, %bf.value1
43   store i32 %7, i32* %4, align 4
44   %bf.value2 = and i32 %y3, 262143
45   %bf.field.offs3 = getelementptr %struct.structx_t, %struct.structx_t* %px, i32 0, i32 0, i32 8
46   %8 = bitcast i8* %bf.field.offs3 to i32*
47   %9 = load i32, i32* %8, align 4
48   %10 = and i32 %9, -262144
49   %11 = or i32 %10, %bf.value2
50   store i32 %11, i32* %8, align 4
51   %bf.value4 = and i32 %y4, 4194303
52   %bf.field.offs5 = getelementptr %struct.structx_t, %struct.structx_t* %px, i32 0, i32 0, i32 12
53   %12 = bitcast i8* %bf.field.offs5 to i32*
54   %13 = load i32, i32* %12, align 4
55   %14 = and i32 %13, -4194304
56   %15 = or i32 %14, %bf.value4
57   store i32 %15, i32* %12, align 4
58   %bf.value6 = and i32 %y5, 4095
59   %bf.field.offs7 = getelementptr %struct.structx_t, %struct.structx_t* %px, i32 0, i32 0, i32 16
60   %16 = bitcast i8* %bf.field.offs7 to i32*
61   %17 = load i32, i32* %16, align 4
62   %18 = and i32 %17, -4096
63   %19 = or i32 %18, %bf.value6
64   store i32 %19, i32* %16, align 4
65   ret void
66 }