63 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 42; RUN: opt -S -passes="separate-const-offset-from-gep<lower-gep>" < %s | FileCheck %s3 4;; Check that or operations, either with operands with no bits in common or that5;; are disjoint are lowered into constant GEPs. Note that because this is a6;; target-independent test, the GEP separator will lower the separated-off constant7;; part to ptrtoint-based arithmetic.8 9define void @testOrDoesntSplit(ptr %p) {10; CHECK-LABEL: define void @testOrDoesntSplit(11; CHECK-SAME: ptr [[P:%.*]]) {12; CHECK-NEXT: [[VAR:%.*]] = tail call i64 @foo()13; CHECK-NEXT: [[OFF:%.*]] = or i64 [[VAR]], 1014; CHECK-NEXT: [[Q:%.*]] = getelementptr i8, ptr [[P]], i64 [[OFF]]15; CHECK-NEXT: store i8 0, ptr [[Q]], align 116; CHECK-NEXT: ret void17;18 %var = tail call i64 @foo()19 %off = or i64 %var, 1020 %q = getelementptr i8, ptr %p, i64 %off21 store i8 0, ptr %q22 ret void23}24 25; COM: The check for `or disjoint` removed the old hasNoBitsInCommon()26; COM: check, ensure that failing to annotate an or with disjoint makes27; COM: the optimization fail.28define void @testNoBitsInCommonOrDoesntSplit(ptr %p) {29; CHECK-LABEL: define void @testNoBitsInCommonOrDoesntSplit(30; CHECK-SAME: ptr [[P:%.*]]) {31; CHECK-NEXT: [[VAR:%.*]] = tail call i64 @foo()32; CHECK-NEXT: [[VAR_HIGH:%.*]] = and i64 [[VAR]], -1633; CHECK-NEXT: [[OFF:%.*]] = or i64 [[VAR_HIGH]], 1034; CHECK-NEXT: [[Q:%.*]] = getelementptr i8, ptr [[P]], i64 [[OFF]]35; CHECK-NEXT: store i8 0, ptr [[Q]], align 136; CHECK-NEXT: ret void37;38 %var = tail call i64 @foo()39 %var.high = and i64 %var, -1640 %off = or i64 %var.high, 1041 %q = getelementptr i8, ptr %p, i64 %off42 store i8 0, ptr %q43 ret void44}45 46define void @testDisjointOrSplits(ptr %p) {47; CHECK-LABEL: define void @testDisjointOrSplits(48; CHECK-SAME: ptr [[P:%.*]]) {49; CHECK-NEXT: [[VAR:%.*]] = tail call i64 @foo()50; CHECK-NEXT: [[UGLYGEP:%.*]] = getelementptr i8, ptr [[P]], i64 [[VAR]]51; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i8, ptr [[UGLYGEP]], i64 1052; CHECK-NEXT: store i8 0, ptr [[TMP4]], align 153; CHECK-NEXT: ret void54;55 %var = tail call i64 @foo()56 %off = or disjoint i64 %var, 1057 %q = getelementptr i8, ptr %p, i64 %off58 store i8 0, ptr %q59 ret void60}61 62declare i64 @foo()63