29 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 22; RUN: opt -S '-passes=separate-const-offset-from-gep<lower-gep>' < %s | FileCheck %s3 4; These tests check that this pass does not incorrectly handle negative offsets.5 6@c = internal constant [4 x i32] [i32 0, i32 1, i32 2, i32 3]7 8; FIXME: We could optimize this case, but we don't currently. This test just9; checks that we don't miscompile it.10define i32 @sub_positive(i32 %a, i32 %b, ptr %ptr) {11; CHECK-LABEL: define i32 @sub_positive12; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]], ptr [[PTR:%.*]]) {13; CHECK-NEXT: entry:14; CHECK-NEXT: [[TMP0:%.*]] = sub nuw nsw i32 15, [[A]]15; CHECK-NEXT: [[TMP1:%.*]] = sub nuw nsw i32 [[B]], [[TMP0]]16; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i6417; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [4 x i32], ptr [[PTR]], i64 0, i64 [[TMP2]]18; CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[TMP3]], align 419; CHECK-NEXT: ret i32 [[TMP4]]20;21entry:22 %0 = sub nuw nsw i32 15, %a23 %1 = sub nuw nsw i32 %b, %024 %2 = zext i32 %1 to i6425 %3 = getelementptr inbounds [4 x i32], ptr %ptr, i64 0, i64 %226 %4 = load i32, ptr %327 ret i32 %428}29