1 ; RUN: opt -S < %s -instcombine | FileCheck %s
3 target datalayout = "e-p1:16:16-p2:32:32-p3:64:64"
5 @G1 = global i32 42, align 1
7 @G3 = global [4 x i8] zeroinitializer, align 1
9 @A1 = alias i32, bitcast (i8* getelementptr inbounds ([4 x i8], [4 x i8]* @G3, i32 0, i32 2) to i32*)
10 @A2 = alias i32, inttoptr (i64 and (i64 ptrtoint (i8* getelementptr inbounds ([4 x i8], [4 x i8]* @G3, i32 0, i32 3) to i64), i64 -4) to i32*)
13 ; This cannot be constant folded because G1 is underaligned.
16 ret i64 and (i64 ptrtoint (i32* @G1 to i64), i64 1)
20 ; The preferred alignment for G2 allows this one to foled to zero.
23 ret i64 and (i64 ptrtoint (i32* @G2 to i64), i64 1)
27 ; This cannot be constant folded because A1 aliases G3 which is underalaigned.
30 ret i64 and (i64 ptrtoint (i32* @A1 to i64), i64 1)
34 ; While A2 also aliases G3 which is underaligned, the math of A2 forces a
35 ; certain alignment allowing this to fold to zero.
38 ret i64 and (i64 ptrtoint (i32* @A2 to i64), i64 1)