1 ; This file checks support for address mode optimization. 2 3 ; RUN: %p2i --filetype=obj --disassemble -i %s --args -O2 \ 4 ; RUN: -allow-externally-defined-symbols | FileCheck %s 5 6 @bytes = internal global [1024 x i8] zeroinitializer 7 8 define internal i32 @load_global_direct() { 9 entry: 10 %base = ptrtoint [1024 x i8]* @bytes to i32 11 %addr_lo.int = add i32 0, %base 12 %addr_hi.int = add i32 4, %base 13 %addr_lo.ptr = inttoptr i32 %addr_lo.int to i32* 14 %addr_hi.ptr = inttoptr i32 %addr_hi.int to i32* 15 %addr_lo.load = load i32, i32* %addr_lo.ptr, align 1 16 %addr_hi.load = load i32, i32* %addr_hi.ptr, align 1 17 %result = add i32 %addr_lo.load, %addr_hi.load 18 ret i32 %result 19 ; CHECK-LABEL: load_global_direct 20 ; CHECK-NEXT: mov eax,{{(DWORD PTR )?}}ds:0x0{{.*}}{{bytes|.bss}} 21 ; CHECK-NEXT: add eax,DWORD PTR ds:0x4{{.*}}{{bytes|.bss}} 22 } 23 24 define internal i32 @load_global_indexed(i32 %arg) { 25 entry: 26 %offset = shl i32 %arg, 3 27 %base = ptrtoint [1024 x i8]* @bytes to i32 28 %addr.int = add i32 %offset, %base 29 %addr.ptr = inttoptr i32 %addr.int to i32* 30 %addr.load = load i32, i32* %addr.ptr, align 1 31 ret i32 %addr.load 32 ; CHECK-LABEL: load_global_indexed 33 ; CHECK-NEXT: mov eax,DWORD PTR [esp+0x4] 34 ; CHECK-NEXT: mov eax,DWORD PTR [eax*8+0x0] 35 } 36