2009-10-23 08:23:49 +02:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
@g1 = constant {{i32,i8},i32} {{i32,i8} { i32 -559038737, i8 186 }, i32 -889275714 }
|
|
|
|
@g2 = constant double 1.0
|
|
|
|
@g3 = constant {i64, i64} { i64 123, i64 112312312 }
|
2009-10-23 08:23:49 +02:00
|
|
|
|
|
|
|
; Simple load
|
|
|
|
define i32 @test1() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret i32 %r
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test1
|
2009-10-23 08:23:49 +02:00
|
|
|
; CHECK: ret i32 -559038737
|
|
|
|
}
|
|
|
|
|
|
|
|
; PR3152
|
|
|
|
; Load of first 16 bits of 32-bit value.
|
|
|
|
define i16 @test2() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret i16 %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test2
|
2009-10-23 08:23:49 +02:00
|
|
|
; CHECK: ret i16 -16657
|
|
|
|
}
|
|
|
|
|
|
|
|
; Load of second 16 bits of 32-bit value.
|
|
|
|
define i16 @test3() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i16* getelementptr(i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 1)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret i16 %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test3
|
2009-10-23 08:23:49 +02:00
|
|
|
; CHECK: ret i16 -8531
|
|
|
|
}
|
|
|
|
|
|
|
|
; Load of 8 bit field + tail padding.
|
|
|
|
define i16 @test4() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i16* getelementptr(i16* bitcast(i32* getelementptr ({{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 2)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret i16 %r
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test4
|
2009-10-23 08:23:49 +02:00
|
|
|
; CHECK: ret i16 186
|
|
|
|
}
|
|
|
|
|
|
|
|
; Load of double bits.
|
|
|
|
define i64 @test6() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i64* bitcast(double* @g2 to i64*)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret i64 %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test6
|
2009-10-23 08:23:49 +02:00
|
|
|
; CHECK: ret i64 4607182418800017408
|
|
|
|
}
|
|
|
|
|
|
|
|
; Load of double bits.
|
|
|
|
define i16 @test7() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i16* bitcast(double* @g2 to i16*)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret i16 %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test7
|
2009-10-23 08:23:49 +02:00
|
|
|
; CHECK: ret i16 0
|
|
|
|
}
|
|
|
|
|
|
|
|
; Double load.
|
|
|
|
define double @test8() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load double* bitcast({{i32,i8},i32}* @g1 to double*)
|
2009-10-23 08:23:49 +02:00
|
|
|
ret double %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test8
|
|
|
|
; CHECK: ret double 0xBADEADBEEF
|
2009-10-23 08:23:49 +02:00
|
|
|
}
|
2009-10-23 08:50:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
; i128 load.
|
|
|
|
define i128 @test9() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load i128* bitcast({i64, i64}* @g3 to i128*)
|
2009-10-23 08:50:36 +02:00
|
|
|
ret i128 %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test9
|
|
|
|
; CHECK: ret i128 2071796475790618158476296315
|
2009-10-23 08:50:36 +02:00
|
|
|
}
|
2009-10-23 08:57:37 +02:00
|
|
|
|
|
|
|
; vector load.
|
|
|
|
define <2 x i64> @test10() {
|
2009-10-24 07:22:15 +02:00
|
|
|
%r = load <2 x i64>* bitcast({i64, i64}* @g3 to <2 x i64>*)
|
2009-10-23 08:57:37 +02:00
|
|
|
ret <2 x i64> %r
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
; CHECK: @test10
|
|
|
|
; CHECK: ret <2 x i64> <i64 123, i64 112312312>
|
2009-10-23 08:57:37 +02:00
|
|
|
}
|
|
|
|
|
2009-10-24 07:22:15 +02:00
|
|
|
|
|
|
|
; PR5287
|
|
|
|
@g4 = internal constant { i8, i8 } { i8 -95, i8 8 }
|
|
|
|
|
|
|
|
define i16 @test11() nounwind {
|
|
|
|
entry:
|
|
|
|
%a = load i16* bitcast ({ i8, i8 }* @g4 to i16*)
|
|
|
|
ret i16 %a
|
|
|
|
|
|
|
|
; CHECK: @test11
|
|
|
|
; CHECK: ret i16 2209
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-04 07:29:29 +01:00
|
|
|
; PR5551
|
|
|
|
@test12g = private constant [6 x i8] c"a\00b\00\00\00"
|
|
|
|
|
|
|
|
define i16 @test12() {
|
|
|
|
%a = load i16* getelementptr inbounds ([3 x i16]* bitcast ([6 x i8]* @test12g to [3 x i16]*), i32 0, i64 1)
|
|
|
|
ret i16 %a
|
|
|
|
; CHECK: @test12
|
|
|
|
; CHECK: ret i16 98
|
|
|
|
}
|
2010-01-08 20:02:23 +01:00
|
|
|
|
|
|
|
|
|
|
|
; PR5978
|
|
|
|
@g5 = constant i8 4
|
|
|
|
define i1 @test13() {
|
|
|
|
%A = load i1* bitcast (i8* @g5 to i1*)
|
|
|
|
ret i1 %A
|
|
|
|
; CHECK: @test13
|
|
|
|
; CHECK: ret i1 false
|
|
|
|
}
|