1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
5 @g1 = constant {{i32,i8},i32} {{i32,i8} { i32 -559038737, i8 186 }, i32 -889275714 }
6 @g2 = constant double 1.0
7 @g3 = constant {i64, i64} { i64 123, i64 112312312 }
11 %r = load i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0)
14 ; CHECK: ret i32 -559038737
18 ; Load of first 16 bits of 32-bit value.
20 %r = load i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*)
24 ; CHECK: ret i16 -16657
27 ; Load of second 16 bits of 32-bit value.
29 %r = load i16* getelementptr(i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 1)
33 ; CHECK: ret i16 -8531
36 ; Load of 8 bit field + tail padding.
38 %r = load i16* getelementptr(i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 2)
44 ; Load of double bits.
46 %r = load i64* bitcast(double* @g2 to i64*)
50 ; CHECK: ret i64 4607182418800017408
53 ; Load of double bits.
55 %r = load i16* bitcast(double* @g2 to i16*)
63 define double @test8() {
64 %r = load double* bitcast({{i32,i8},i32}* @g1 to double*)
68 ; CHECK: ret double 0xBADEADBEEF
73 define i128 @test9() {
74 %r = load i128* bitcast({i64, i64}* @g3 to i128*)
78 ; CHECK: ret i128 2071796475790618158476296315
82 define <2 x i64> @test10() {
83 %r = load <2 x i64>* bitcast({i64, i64}* @g3 to <2 x i64>*)
87 ; CHECK: ret <2 x i64> <i64 123, i64 112312312>
92 @g4 = internal constant { i8, i8 } { i8 -95, i8 8 }
94 define i16 @test11() nounwind {
96 %a = load i16* bitcast ({ i8, i8 }* @g4 to i16*)
100 ; CHECK: ret i16 2209
105 @test12g = private constant [6 x i8] c"a\00b\00\00\00"
107 define i16 @test12() {
108 %a = load i16* getelementptr inbounds ([3 x i16]* bitcast ([6 x i8]* @test12g to [3 x i16]*), i32 0, i64 1)
117 define i1 @test13() {
118 %A = load i1* bitcast (i8* @g5 to i1*)
121 ; CHECK: ret i1 false