brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 63148f5 Raw
69 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=separate-const-offset-from-gep < %s | FileCheck %s3 4target triple = "aarch64-linux-gnu"5 6; Index is implicitly multiplied by vscale and so not really constant.7define ptr @test1(ptr %base, i64 %idx) #0 {8; CHECK-LABEL: @test1(9; CHECK-NEXT:    [[IDX_NEXT:%.*]] = add nuw nsw i64 [[IDX:%.*]], 110; CHECK-NEXT:    [[GEP:%.*]] = getelementptr <vscale x 4 x float>, ptr [[BASE:%.*]], i64 [[IDX_NEXT]]11; CHECK-NEXT:    ret ptr [[GEP]]12;13  %idx.next = add nuw nsw i64 %idx, 114  %gep = getelementptr <vscale x 4 x float>, ptr %base, i64 %idx.next15  ret ptr %gep16}17 18; Whilst the first index is not constant, the calculation of the second index19; does contain a constant that can be extracted.20define ptr @test2(ptr %base, i64 %idx) {21; CHECK-LABEL: @test2(22; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr <vscale x 4 x float>, ptr [[BASE:%.*]], i64 3, i64 [[IDX:%.*]]23; CHECK-NEXT:    [[GEP2:%.*]] = getelementptr i8, ptr [[TMP1]], i64 424; CHECK-NEXT:    ret ptr [[GEP2]]25;26  %idx.next = add nuw nsw i64 %idx, 127  %gep = getelementptr <vscale x 4 x float>, ptr %base, i64 3, i64 %idx.next28  ret ptr %gep29}30 31; Index is implicitly multiplied by vscale and so not really constant.32define ptr @test3(ptr %base, i64 %idx) #0 {33; CHECK-LABEL: @test3(34; CHECK-NEXT:    [[IDX_NEXT:%.*]] = add nuw nsw i64 [[IDX:%.*]], 135; CHECK-NEXT:    [[GEP:%.*]] = getelementptr [8 x <vscale x 4 x float>], ptr [[BASE:%.*]], i64 [[IDX_NEXT]]36; CHECK-NEXT:    ret ptr [[GEP]]37;38  %idx.next = add nuw nsw i64 %idx, 139  %gep = getelementptr [8 x <vscale x 4 x float>], ptr %base, i64 %idx.next40  ret ptr %gep41}42 43; Indices are implicitly multiplied by vscale and so not really constant.44define ptr @test4(ptr %base, i64 %idx) {45; CHECK-LABEL: @test4(46; CHECK-NEXT:    [[IDX_NEXT:%.*]] = add nuw nsw i64 [[IDX:%.*]], 147; CHECK-NEXT:    [[GEP:%.*]] = getelementptr [8 x <vscale x 4 x float>], ptr [[BASE:%.*]], i64 3, i64 [[IDX_NEXT]]48; CHECK-NEXT:    ret ptr [[GEP]]49;50  %idx.next = add nuw nsw i64 %idx, 151  %gep = getelementptr [8 x <vscale x 4 x float>], ptr %base, i64 3, i64 %idx.next52  ret ptr %gep53}54 55; Whilst the first two indices are not constant, the calculation of the third56; index does contain a constant that can be extracted.57define ptr @test5(ptr %base, i64 %idx) {58; CHECK-LABEL: @test5(59; CHECK-NEXT:    [[TMP1:%.*]] = getelementptr [8 x <vscale x 4 x float>], ptr [[BASE:%.*]], i64 1, i64 3, i64 [[IDX:%.*]]60; CHECK-NEXT:    [[GEP2:%.*]] = getelementptr i8, ptr [[TMP1]], i64 461; CHECK-NEXT:    ret ptr [[GEP2]]62;63  %idx.next = add nuw nsw i64 %idx, 164  %gep = getelementptr [8 x <vscale x 4 x float>], ptr %base, i64 1, i64 3, i64 %idx.next65  ret ptr %gep66}67 68attributes #0 = { "target-features"="+sve" }69