208 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 62; RUN: opt -passes='print<access-info>' -disable-output %s 2>&1 | FileCheck %s3 4; unsigned long long s0 = 0, s1 = 0;5; for (int i = 0; i < 100; i++) {6; if (i % 4 == 0) {7; A[s0] = 2; // A[0], A[4], A[8], A[12], ...8; A[s1] = 1; // A[0], A[8], A[16], A[24], ...9; }10; s0 += (1ULL << 62) + 1;11; s1 += (1ULL << 62) + 2;12; }13; We cannot use inbounds on idx.0, idx.1 to infer no-wrap (and determine14; there are no dependences), as the pointers are not dereferenced in all loop iterations.15define void @test_inbounds_gep_used_in_predicated_block(ptr %A, i64 %n) {16; CHECK-LABEL: 'test_inbounds_gep_used_in_predicated_block'17; CHECK-NEXT: loop.header:18; CHECK-NEXT: Memory dependences are safe19; CHECK-NEXT: Dependences:20; CHECK-NEXT: Run-time memory checks:21; CHECK-NEXT: Grouped accesses:22; CHECK-NEXT: Group GRP0:23; CHECK-NEXT: (Low: %A High: (-4611686018427387705 + %A))24; CHECK-NEXT: Member: {%A,+,4611686018427387906}<%loop.header>25; CHECK-NEXT: Member: {%A,+,4611686018427387905}<%loop.header>26; CHECK-EMPTY:27; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.28; CHECK-NEXT: SCEV assumptions:29; CHECK-NEXT: {%A,+,4611686018427387906}<%loop.header> Added Flags: <nusw>30; CHECK-EMPTY:31; CHECK-NEXT: Expressions re-written:32;33entry:34 br label %loop.header35 36loop.header:37 %i = phi i64 [ 0, %entry ], [ %i.next, %loop.latch ]38 %offset.0 = phi i64 [ 0, %entry ], [ %offset.0.next, %loop.latch ]39 %offset.1 = phi i64 [ 0, %entry ], [ %offset.1.next, %loop.latch ]40 %idx.0 = getelementptr inbounds i8, ptr %A, i64 %offset.041 %idx.1 = getelementptr inbounds i8, ptr %A, i64 %offset.142 %mask = and i64 %i, 343 %cond = icmp eq i64 %mask, 044 br i1 %cond, label %if.then, label %loop.latch45 46if.then:47 store i8 2, ptr %idx.048 store i8 1, ptr %idx.149 br label %loop.latch50 51loop.latch:52 %i.next = add nuw nsw i64 %i, 153 %offset.0.next = add i64 %offset.0, 4611686018427387905 ; 2^62 + 154 %offset.1.next = add i64 %offset.1, 4611686018427387906 ; 2^62 + 255 %cond.exit = icmp eq i64 %i.next, 10056 br i1 %cond.exit, label %exit, label %loop.header57 58exit:59 ret void60}61 62; Same as @test_inbounds_gep_used_in_predicated_block, but also storing the63; pointer values in the header.64define void @test_inbounds_gep_used_in_predicated_block_stored_value_operand(ptr %A, i64 %n, ptr noalias %B) {65; CHECK-LABEL: 'test_inbounds_gep_used_in_predicated_block_stored_value_operand'66; CHECK-NEXT: loop.header:67; CHECK-NEXT: Memory dependences are safe68; CHECK-NEXT: Dependences:69; CHECK-NEXT: Run-time memory checks:70; CHECK-NEXT: Grouped accesses:71; CHECK-NEXT: Group GRP0:72; CHECK-NEXT: (Low: %A High: (-4611686018427387705 + %A))73; CHECK-NEXT: Member: {%A,+,4611686018427387906}<%loop.header>74; CHECK-NEXT: Member: {%A,+,4611686018427387905}<%loop.header>75; CHECK-EMPTY:76; CHECK-NEXT: Non vectorizable stores to invariant address were found in loop.77; CHECK-NEXT: SCEV assumptions:78; CHECK-NEXT: {%A,+,4611686018427387906}<%loop.header> Added Flags: <nusw>79; CHECK-EMPTY:80; CHECK-NEXT: Expressions re-written:81;82entry:83 br label %loop.header84 85loop.header:86 %i = phi i64 [ 0, %entry ], [ %i.next, %loop.latch ]87 %offset.0 = phi i64 [ 0, %entry ], [ %offset.0.next, %loop.latch ]88 %offset.1 = phi i64 [ 0, %entry ], [ %offset.1.next, %loop.latch ]89 %idx.0 = getelementptr inbounds i8, ptr %A, i64 %offset.090 %idx.1 = getelementptr inbounds i8, ptr %A, i64 %offset.191 %mask = and i64 %i, 392 %cond = icmp eq i64 %mask, 093 store ptr %idx.0, ptr %B94 store ptr %idx.1, ptr %B95 br i1 %cond, label %if.then, label %loop.latch96 97if.then:98 store i8 2, ptr %idx.099 store i8 1, ptr %idx.1100 br label %loop.latch101 102loop.latch:103 %i.next = add nuw nsw i64 %i, 1104 %offset.0.next = add i64 %offset.0, 4611686018427387905 ; 2^62 + 1105 %offset.1.next = add i64 %offset.1, 4611686018427387906 ; 2^62 + 2106 %cond.exit = icmp eq i64 %i.next, 100107 br i1 %cond.exit, label %exit, label %loop.header108 109exit:110 ret void111}112 113; Same as @test_inbounds_gep_used_in_predicated_block_non_memop_user, but with114; extra GEP users in the header.115define void @test_inbounds_gep_used_in_predicated_block_non_memop_user(ptr %A, i64 %n) {116; CHECK-LABEL: 'test_inbounds_gep_used_in_predicated_block_non_memop_user'117; CHECK-NEXT: loop.header:118; CHECK-NEXT: Memory dependences are safe119; CHECK-NEXT: Dependences:120; CHECK-NEXT: Run-time memory checks:121; CHECK-NEXT: Grouped accesses:122; CHECK-NEXT: Group GRP0:123; CHECK-NEXT: (Low: %A High: (-4611686018427387705 + %A))124; CHECK-NEXT: Member: {%A,+,4611686018427387906}<%loop.header>125; CHECK-NEXT: Member: {%A,+,4611686018427387905}<%loop.header>126; CHECK-EMPTY:127; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.128; CHECK-NEXT: SCEV assumptions:129; CHECK-NEXT: {%A,+,4611686018427387906}<%loop.header> Added Flags: <nusw>130; CHECK-EMPTY:131; CHECK-NEXT: Expressions re-written:132;133entry:134 br label %loop.header135 136loop.header:137 %i = phi i64 [ 0, %entry ], [ %i.next, %loop.latch ]138 %offset.0 = phi i64 [ 0, %entry ], [ %offset.0.next, %loop.latch ]139 %offset.1 = phi i64 [ 0, %entry ], [ %offset.1.next, %loop.latch ]140 %idx.0 = getelementptr inbounds i8, ptr %A, i64 %offset.0141 %idx.1 = getelementptr inbounds i8, ptr %A, i64 %offset.1142 %mask = and i64 %i, 3143 %cond = icmp eq i64 %mask, 0144 %gep.idx.0 = getelementptr inbounds i8, ptr %idx.0, i8 1145 %gep.idx.1 = getelementptr inbounds i8, ptr %idx.1, i8 1146 br i1 %cond, label %if.then, label %loop.latch147 148if.then:149 store i8 2, ptr %idx.0150 store i8 1, ptr %idx.1151 br label %loop.latch152 153loop.latch:154 %i.next = add nuw nsw i64 %i, 1155 %offset.0.next = add i64 %offset.0, 4611686018427387905 ; 2^62 + 1156 %offset.1.next = add i64 %offset.1, 4611686018427387906 ; 2^62 + 2157 %cond.exit = icmp eq i64 %i.next, 100158 br i1 %cond.exit, label %exit, label %loop.header159 160exit:161 store i32 0, ptr %gep.idx.0162 store i32 0, ptr %gep.idx.1163 ret void164}165 166define void @test_header_existing(ptr %src, ptr %dst, i64 %start) {167; CHECK-LABEL: 'test_header_existing'168; CHECK-NEXT: loop.header:169; CHECK-NEXT: Memory dependences are safe with run-time checks170; CHECK-NEXT: Dependences:171; CHECK-NEXT: Run-time memory checks:172; CHECK-NEXT: Check 0:173; CHECK-NEXT: Comparing group GRP0:174; CHECK-NEXT: ptr %dst175; CHECK-NEXT: Against group GRP1:176; CHECK-NEXT: %gep.src = getelementptr nusw { i8, i8, i32 }, ptr %src, i64 %iv.next177; CHECK-NEXT: Grouped accesses:178; CHECK-NEXT: Group GRP0:179; CHECK-NEXT: (Low: %dst High: (1 + %dst))180; CHECK-NEXT: Member: %dst181; CHECK-NEXT: Group GRP1:182; CHECK-NEXT: (Low: (8 + (8 * %start) + %src) High: (809 + %src))183; CHECK-NEXT: Member: {(8 + (8 * %start) + %src),+,8}<%loop.header>184; CHECK-EMPTY:185; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.186; CHECK-NEXT: SCEV assumptions:187; CHECK-EMPTY:188; CHECK-NEXT: Expressions re-written:189;190entry:191 br label %loop.header192 193loop.header:194 %iv = phi i64 [ %start, %entry ], [ %iv.next, %loop.latch ]195 %ec = icmp eq i64 %iv, 100196 br i1 %ec, label %exit, label %loop.latch197 198loop.latch:199 %iv.next = add i64 %iv, 1200 %gep.src = getelementptr nusw { i8, i8, i32 }, ptr %src, i64 %iv.next201 %l = load i8, ptr %gep.src, align 1202 store i8 %l, ptr %dst, align 1203 br label %loop.header204 205exit:206 ret void207}208