xref: /llvm-project/llvm/test/Transforms/ConstantHoisting/PowerPC/const-base-addr.ll (revision 055fb7795aa219a3d274d280ec9129784f169f56)
133b939c3SRoman Lebedev; RUN: opt -S -passes=consthoist < %s | FileCheck %s
2cee313d2SEric Christophertarget datalayout = "E-m:e-i64:64-n32:64"
3cee313d2SEric Christophertarget triple = "powerpc64-unknown-linux-gnu"
4cee313d2SEric Christopher
5cee313d2SEric Christopher%T = type { i32, i32, i32, i32 }
6cee313d2SEric Christopher
7cee313d2SEric Christopher; Test if even cheap base addresses are hoisted.
8cee313d2SEric Christopherdefine i32 @test1() nounwind {
9cee313d2SEric Christopher; CHECK-LABEL:  @test1
10cee313d2SEric Christopher; CHECK:        %const = bitcast i32 12345678 to i32
11*055fb779SNikita Popov; CHECK:        %1 = inttoptr i32 %const to ptr
12*055fb779SNikita Popov; CHECK:        %addr1 = getelementptr %T, ptr %1, i32 0, i32 1
13*055fb779SNikita Popov  %addr1 = getelementptr %T, ptr inttoptr (i32 12345678 to ptr), i32 0, i32 1
14*055fb779SNikita Popov  %tmp1 = load i32, ptr %addr1
15*055fb779SNikita Popov  %addr2 = getelementptr %T, ptr inttoptr (i32 12345678 to ptr), i32 0, i32 2
16*055fb779SNikita Popov  %tmp2 = load i32, ptr %addr2
17*055fb779SNikita Popov  %addr3 = getelementptr %T, ptr inttoptr (i32 12345678 to ptr), i32 0, i32 3
18*055fb779SNikita Popov  %tmp3 = load i32, ptr %addr3
19cee313d2SEric Christopher  %tmp4 = add i32 %tmp1, %tmp2
20cee313d2SEric Christopher  %tmp5 = add i32 %tmp3, %tmp4
21cee313d2SEric Christopher  ret i32 %tmp5
22cee313d2SEric Christopher}
23cee313d2SEric Christopher
24