2017-02-18 01:36:52 +08:00
|
|
|
; RUN: opt < %s -data-layout="e-p:64:64:64-p1:16:16:16-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" -instcombine -S | FileCheck %s --check-prefix=LE
|
|
|
|
; RUN: opt < %s -data-layout="E-p:64:64:64-p1:16:16:16-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" -instcombine -S | FileCheck %s --check-prefix=BE
|
2009-10-23 14:23:49 +08:00
|
|
|
|
2012-11-09 04:34:25 +08:00
|
|
|
; {{ 0xDEADBEEF, 0xBA }, 0xCAFEBABE}
|
2009-10-24 13:22:15 +08:00
|
|
|
@g1 = constant {{i32,i8},i32} {{i32,i8} { i32 -559038737, i8 186 }, i32 -889275714 }
|
|
|
|
@g2 = constant double 1.0
|
2012-11-09 04:34:25 +08:00
|
|
|
; { 0x7B, 0x06B1BFF8 }
|
2009-10-24 13:22:15 +08:00
|
|
|
@g3 = constant {i64, i64} { i64 123, i64 112312312 }
|
2009-10-23 14:23:49 +08:00
|
|
|
|
|
|
|
; Simple load
|
|
|
|
define i32 @test1() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%r = load i32, i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret i32 %r
|
2012-11-09 04:34:25 +08:00
|
|
|
|
|
|
|
; 0xDEADBEEF
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test1(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i32 -559038737
|
|
|
|
|
|
|
|
; 0xDEADBEEF
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test1(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i32 -559038737
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; PR3152
|
|
|
|
; Load of first 16 bits of 32-bit value.
|
|
|
|
define i16 @test2() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%r = load i16, i16* bitcast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret i16 %r
|
|
|
|
|
2012-11-09 04:34:25 +08:00
|
|
|
; 0xBEEF
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test2(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i16 -16657
|
|
|
|
|
|
|
|
; 0xDEAD
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test2(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i16 -8531
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
|
|
|
|
2014-07-15 06:39:26 +08:00
|
|
|
define i16 @test2_addrspacecast() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%r = load i16, i16 addrspace(1)* addrspacecast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16 addrspace(1)*)
|
2014-07-15 06:39:26 +08:00
|
|
|
ret i16 %r
|
|
|
|
|
2015-07-28 02:31:03 +08:00
|
|
|
; FIXME: Should be able to load through a constant addrspacecast.
|
2014-07-15 06:39:26 +08:00
|
|
|
; 0xBEEF
|
|
|
|
; LE-LABEL: @test2_addrspacecast(
|
2015-07-28 02:31:03 +08:00
|
|
|
; XLE: ret i16 -16657
|
|
|
|
; LE: load i16, i16 addrspace(1)* addrspacecast
|
2014-07-15 06:39:26 +08:00
|
|
|
|
|
|
|
; 0xDEAD
|
|
|
|
; BE-LABEL: @test2_addrspacecast(
|
2015-07-28 02:31:03 +08:00
|
|
|
; XBE: ret i16 -8531
|
|
|
|
; BE: load i16, i16 addrspace(1)* addrspacecast
|
2014-07-15 06:39:26 +08:00
|
|
|
}
|
|
|
|
|
2009-10-23 14:23:49 +08:00
|
|
|
; Load of second 16 bits of 32-bit value.
|
|
|
|
define i16 @test3() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%r = load i16, i16* getelementptr(i16, i16* bitcast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 1)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret i16 %r
|
|
|
|
|
2012-11-09 04:34:25 +08:00
|
|
|
; 0xDEAD
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test3(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i16 -8531
|
|
|
|
|
|
|
|
; 0xBEEF
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test3(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i16 -16657
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; Load of 8 bit field + tail padding.
|
|
|
|
define i16 @test4() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%r = load i16, i16* getelementptr(i16, i16* bitcast(i32* getelementptr ({{i32,i8},i32}, {{i32,i8},i32}* @g1, i32 0, i32 0, i32 0) to i16*), i32 2)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret i16 %r
|
2012-11-09 04:34:25 +08:00
|
|
|
|
|
|
|
; 0x00BA
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test4(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i16 186
|
|
|
|
|
|
|
|
; 0xBA00
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test4(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i16 -17920
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; Load of double bits.
|
|
|
|
define i64 @test6() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%r = load i64, i64* bitcast(double* @g2 to i64*)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
|
2012-11-09 04:34:25 +08:00
|
|
|
; 0x3FF_0000000000000
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test6(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i64 4607182418800017408
|
|
|
|
|
|
|
|
; 0x3FF_0000000000000
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test6(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i64 4607182418800017408
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; Load of double bits.
|
|
|
|
define i16 @test7() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%r = load i16, i16* bitcast(double* @g2 to i16*)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret i16 %r
|
|
|
|
|
2012-11-09 04:34:25 +08:00
|
|
|
; 0x0000
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test7(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i16 0
|
|
|
|
|
|
|
|
; 0x3FF0
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test7(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i16 16368
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; Double load.
|
|
|
|
define double @test8() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%r = load double, double* bitcast({{i32,i8},i32}* @g1 to double*)
|
2009-10-23 14:23:49 +08:00
|
|
|
ret double %r
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test8(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret double 0xBADEADBEEF
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test8(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret double 0xDEADBEEFBA000000
|
2009-10-23 14:23:49 +08:00
|
|
|
}
|
2009-10-23 14:50:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
; i128 load.
|
|
|
|
define i128 @test9() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%r = load i128, i128* bitcast({i64, i64}* @g3 to i128*)
|
2009-10-23 14:50:36 +08:00
|
|
|
ret i128 %r
|
|
|
|
|
2012-11-09 04:34:25 +08:00
|
|
|
; 0x00000000_06B1BFF8_00000000_0000007B
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test9(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i128 2071796475790618158476296315
|
|
|
|
|
|
|
|
; 0x00000000_0000007B_00000000_06B1BFF8
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test9(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i128 2268949521066387161080
|
2009-10-23 14:50:36 +08:00
|
|
|
}
|
2009-10-23 14:57:37 +08:00
|
|
|
|
|
|
|
; vector load.
|
|
|
|
define <2 x i64> @test10() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%r = load <2 x i64>, <2 x i64>* bitcast({i64, i64}* @g3 to <2 x i64>*)
|
2009-10-23 14:57:37 +08:00
|
|
|
ret <2 x i64> %r
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test10(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret <2 x i64> <i64 123, i64 112312312>
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test10(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret <2 x i64> <i64 123, i64 112312312>
|
2009-10-23 14:57:37 +08:00
|
|
|
}
|
|
|
|
|
2009-10-24 13:22:15 +08:00
|
|
|
|
|
|
|
; PR5287
|
2012-11-09 04:34:25 +08:00
|
|
|
; { 0xA1, 0x08 }
|
2009-10-24 13:22:15 +08:00
|
|
|
@g4 = internal constant { i8, i8 } { i8 -95, i8 8 }
|
|
|
|
|
|
|
|
define i16 @test11() nounwind {
|
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%a = load i16, i16* bitcast ({ i8, i8 }* @g4 to i16*)
|
2009-10-24 13:22:15 +08:00
|
|
|
ret i16 %a
|
2012-11-09 04:34:25 +08:00
|
|
|
|
|
|
|
; 0x08A1
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test11(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i16 2209
|
|
|
|
|
|
|
|
; 0xA108
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test11(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i16 -24312
|
2009-10-24 13:22:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-04 14:29:29 +08:00
|
|
|
; PR5551
|
|
|
|
@test12g = private constant [6 x i8] c"a\00b\00\00\00"
|
|
|
|
|
|
|
|
define i16 @test12() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%a = load i16, i16* getelementptr inbounds ([3 x i16], [3 x i16]* bitcast ([6 x i8]* @test12g to [3 x i16]*), i32 0, i64 1)
|
2009-12-04 14:29:29 +08:00
|
|
|
ret i16 %a
|
2012-11-09 04:34:25 +08:00
|
|
|
|
|
|
|
; 0x0062
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test12(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i16 98
|
|
|
|
|
|
|
|
; 0x6200
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test12(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i16 25088
|
2009-12-04 14:29:29 +08:00
|
|
|
}
|
2010-01-09 03:02:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
; PR5978
|
|
|
|
@g5 = constant i8 4
|
|
|
|
define i1 @test13() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%A = load i1, i1* bitcast (i8* @g5 to i1*)
|
2010-01-09 03:02:23 +08:00
|
|
|
ret i1 %A
|
2012-11-09 04:34:25 +08:00
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test13(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i1 false
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test13(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i1 false
|
2010-01-09 03:02:23 +08:00
|
|
|
}
|
2011-02-07 04:11:56 +08:00
|
|
|
|
|
|
|
@g6 = constant [2 x i8*] [i8* inttoptr (i64 1 to i8*), i8* inttoptr (i64 2 to i8*)]
|
|
|
|
define i64 @test14() nounwind {
|
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i64, i64* bitcast ([2 x i8*]* @g6 to i64*)
|
2011-02-07 04:11:56 +08:00
|
|
|
ret i64 %tmp
|
2012-11-09 04:34:25 +08:00
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test14(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i64 1
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test14(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i64 1
|
2011-02-07 04:11:56 +08:00
|
|
|
}
|
|
|
|
|
2013-08-21 05:20:04 +08:00
|
|
|
; Check with address space pointers
|
|
|
|
@g6_as1 = constant [2 x i8 addrspace(1)*] [i8 addrspace(1)* inttoptr (i16 1 to i8 addrspace(1)*), i8 addrspace(1)* inttoptr (i16 2 to i8 addrspace(1)*)]
|
|
|
|
define i16 @test14_as1() nounwind {
|
|
|
|
entry:
|
2015-02-28 05:17:42 +08:00
|
|
|
%tmp = load i16, i16* bitcast ([2 x i8 addrspace(1)*]* @g6_as1 to i16*)
|
2013-08-21 05:20:04 +08:00
|
|
|
ret i16 %tmp
|
|
|
|
|
|
|
|
; LE: @test14_as1
|
|
|
|
; LE: ret i16 1
|
|
|
|
|
|
|
|
; BE: @test14_as1
|
|
|
|
; BE: ret i16 1
|
|
|
|
}
|
|
|
|
|
2011-02-07 04:11:56 +08:00
|
|
|
define i64 @test15() nounwind {
|
|
|
|
entry:
|
2015-03-14 02:20:45 +08:00
|
|
|
%tmp = load i64, i64* bitcast (i8** getelementptr inbounds ([2 x i8*], [2 x i8*]* @g6, i32 0, i64 1) to i64*)
|
2011-02-07 04:11:56 +08:00
|
|
|
ret i64 %tmp
|
2012-11-09 04:34:25 +08:00
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; LE-LABEL: @test15(
|
2012-11-09 04:34:25 +08:00
|
|
|
; LE: ret i64 2
|
|
|
|
|
2013-07-14 09:42:54 +08:00
|
|
|
; BE-LABEL: @test15(
|
2012-11-09 04:34:25 +08:00
|
|
|
; BE: ret i64 2
|
2011-02-07 04:11:56 +08:00
|
|
|
}
|
2014-05-15 17:56:28 +08:00
|
|
|
|
|
|
|
@gv7 = constant [4 x i8*] [i8* null, i8* inttoptr (i64 -14 to i8*), i8* null, i8* null]
|
|
|
|
define i64 @test16.1() {
|
2015-02-28 05:17:42 +08:00
|
|
|
%v = load i64, i64* bitcast ([4 x i8*]* @gv7 to i64*), align 8
|
2014-05-15 17:56:28 +08:00
|
|
|
ret i64 %v
|
|
|
|
|
|
|
|
; LE-LABEL: @test16.1(
|
|
|
|
; LE: ret i64 0
|
|
|
|
|
|
|
|
; BE-LABEL: @test16.1(
|
|
|
|
; BE: ret i64 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test16.2() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%v = load i64, i64* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @gv7, i64 0, i64 1) to i64*), align 8
|
2014-05-15 17:56:28 +08:00
|
|
|
ret i64 %v
|
|
|
|
|
|
|
|
; LE-LABEL: @test16.2(
|
|
|
|
; LE: ret i64 -14
|
|
|
|
|
|
|
|
; BE-LABEL: @test16.2(
|
|
|
|
; BE: ret i64 -14
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @test16.3() {
|
2015-03-14 02:20:45 +08:00
|
|
|
%v = load i64, i64* bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @gv7, i64 0, i64 2) to i64*), align 8
|
2014-05-15 17:56:28 +08:00
|
|
|
ret i64 %v
|
|
|
|
|
|
|
|
; LE-LABEL: @test16.3(
|
|
|
|
; LE: ret i64 0
|
|
|
|
|
|
|
|
; BE-LABEL: @test16.3(
|
|
|
|
; BE: ret i64 0
|
|
|
|
}
|