brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · abca77e Raw
40 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22; RUN: opt -S < %s -passes=instcombine | FileCheck %s3 4target datalayout = "e-p1:16:16-p2:32:32-p3:64:64"5 6@G1 = global i32 42, align 17@G2 = global i32 428@G3 = global [4 x i8] zeroinitializer, align 19 10@A1 = alias i32, getelementptr inbounds ([4 x i8], ptr @G3, i32 0, i32 2)11 12define i64 @f1() {13; This cannot be constant folded because G1 is underaligned.14; CHECK-LABEL: define i64 @f1() {15; CHECK-NEXT:    [[AND:%.*]] = and i64 ptrtoint (ptr @G1 to i64), 116; CHECK-NEXT:    ret i64 [[AND]]17;18  %and = and i64 ptrtoint (ptr @G1 to i64), 119  ret i64 %and20}21 22define i64 @f2() {23; The preferred alignment for G2 allows this one to foled to zero.24; CHECK-LABEL: define i64 @f2() {25; CHECK-NEXT:    ret i64 026;27  %and = and i64 ptrtoint (ptr @G2 to i64), 128  ret i64 %and29}30 31define i64 @g1() {32; This cannot be constant folded because A1 aliases G3 which is underalaigned.33; CHECK-LABEL: define i64 @g1() {34; CHECK-NEXT:    [[AND:%.*]] = and i64 ptrtoint (ptr @A1 to i64), 135; CHECK-NEXT:    ret i64 [[AND]]36;37  %and = and i64 ptrtoint (ptr @A1 to i64), 138  ret i64 %and39}40