brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · 5d39ad4 Raw
69 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=instcombine < %s | FileCheck %s3 4; This test is used to verify we are not crashing at Assertion `CastInst::castIsValid(opc, C, Ty) && "Invalid constantexpr cast!".5define <vscale x 2 x ptr> @gep_index_type_is_scalable(ptr %p) {6; CHECK-LABEL: @gep_index_type_is_scalable(7; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[P:%.*]], <vscale x 2 x i64> undef8; CHECK-NEXT:    ret <vscale x 2 x ptr> [[GEP]]9;10  %gep = getelementptr i8, ptr %p, <vscale x 2 x i64> undef11  ret <vscale x 2 x ptr> %gep12}13 14; This test serves to verify code changes for "GEP.getNumIndices() == 1".15define ptr @gep_num_of_indices_1(ptr %p) {16; CHECK-LABEL: @gep_num_of_indices_1(17; CHECK-NEXT:    [[TMP1:%.*]] = call i64 @llvm.vscale.i64()18; CHECK-NEXT:    [[TMP2:%.*]] = shl nuw i64 [[TMP1]], 419; CHECK-NEXT:    [[GEP:%.*]] = getelementptr i8, ptr [[P:%.*]], i64 [[TMP2]]20; CHECK-NEXT:    ret ptr [[GEP]]21;22  %gep = getelementptr <vscale x 4 x i32>, ptr %p, i64 123  ret ptr %gep24}25 26; This test serves to verify code changes for "GEP.getNumOperands() == 2".27define void @gep_bitcast(ptr %p) {28; CHECK-LABEL: @gep_bitcast(29; CHECK-NEXT:    store <vscale x 16 x i8> zeroinitializer, ptr [[P:%.*]], align 1630; CHECK-NEXT:    [[TMP1:%.*]] = call i64 @llvm.vscale.i64()31; CHECK-NEXT:    [[TMP2:%.*]] = shl nuw i64 [[TMP1]], 432; CHECK-NEXT:    [[GEP2:%.*]] = getelementptr i8, ptr [[P]], i64 [[TMP2]]33; CHECK-NEXT:    store <vscale x 16 x i8> zeroinitializer, ptr [[GEP2]], align 1634; CHECK-NEXT:    ret void35;36  store <vscale x 16 x i8> zeroinitializer, ptr %p37  %gep2 = getelementptr <vscale x 16 x i8>, ptr %p, i64 138  store <vscale x 16 x i8> zeroinitializer, ptr %gep239  ret void40}41 42; These tests serve to verify code changes when underlying gep ptr is alloca.43; This test is to verify 'inbounds' is added when it's valid to accumulate constant offset.44define i32 @gep_alloca_inbounds_vscale_zero(ptr %a) {45; CHECK-LABEL: @gep_alloca_inbounds_vscale_zero(46; CHECK-NEXT:    [[TMP:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 847; CHECK-NEXT:    [[LOAD:%.*]] = load i32, ptr [[TMP]], align 448; CHECK-NEXT:    ret i32 [[LOAD]]49;50  %tmp = getelementptr <vscale x 4 x i32>, ptr %a, i32 0, i32 251  %load = load i32, ptr %tmp52  ret i32 %load53}54 55; This test is to verify 'inbounds' is not added when a constant offset can not be determined at compile-time.56define i32 @gep_alloca_inbounds_vscale_nonzero(ptr %a) {57; CHECK-LABEL: @gep_alloca_inbounds_vscale_nonzero(58; CHECK-NEXT:    [[TMP1:%.*]] = call i64 @llvm.vscale.i64()59; CHECK-NEXT:    [[TMP2:%.*]] = shl nuw i64 [[TMP1]], 460; CHECK-NEXT:    [[TMP3:%.*]] = getelementptr i8, ptr [[A:%.*]], i64 [[TMP2]]61; CHECK-NEXT:    [[TMP:%.*]] = getelementptr i8, ptr [[TMP3]], i64 862; CHECK-NEXT:    [[LOAD:%.*]] = load i32, ptr [[TMP]], align 463; CHECK-NEXT:    ret i32 [[LOAD]]64;65  %tmp = getelementptr <vscale x 4 x i32>, ptr %a, i32 1, i32 266  %load = load i32, ptr %tmp67  ret i32 %load68}69