| ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --filter "forced scalar" --filter "VF [0-9]+: CLONE ir<%(idx|iv.shl|off|gep)" --filter "Cost for VF" --version 6 | |
| ; REQUIRES: asserts | |
| ; RUN: opt -passes=loop-vectorize -mtriple=x86_64-unknown-linux-gnu -mattr=+avx -debug-only=loop-vectorize -disable-output < %s 2>&1 | FileCheck %s | |
| ; The address computation of the second store group member is dead. | |
| define void @interleave_store_factor_2(ptr noalias %src, ptr noalias %dst) { | |
| ; CHECK-LABEL: 'interleave_store_factor_2' | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[VP4:%[0-9]+]]> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%idx.0> = shl nuw nsw vp<[[VP4]]>, ir<1> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.dst.0> = getelementptr inbounds ir<%dst>, ir<%idx.0> | |
| ; CHECK: Cost for VF 2: 7 (Estimated cost per lane: 3.5) | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[VP4]]> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%idx.0> = shl nuw nsw vp<[[VP4]]>, ir<1> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.dst.0> = getelementptr inbounds ir<%dst>, ir<%idx.0> | |
| ; CHECK: Cost for VF 4: 23 (Estimated cost per lane: 5.75) | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[VP4]]> | |
| ; CHECK: Cost of 1 for VF 8: CLONE ir<%idx.0> = shl nuw nsw vp<[[VP4]]>, ir<1> | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.dst.0> = getelementptr inbounds ir<%dst>, ir<%idx.0> | |
| ; CHECK: Cost for VF 8: 46 (Estimated cost per lane: 5.75) | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] | |
| %gep.src = getelementptr inbounds i32, ptr %src, i64 %iv | |
| %l = load i32, ptr %gep.src | |
| %add = add i32 %l, 1 | |
| %idx.0 = shl nuw nsw i64 %iv, 1 | |
| %idx.1 = or disjoint i64 %idx.0, 1 | |
| %gep.dst.0 = getelementptr inbounds i32, ptr %dst, i64 %idx.0 | |
| %gep.dst.1 = getelementptr inbounds i32, ptr %dst, i64 %idx.1 | |
| store i32 %l, ptr %gep.dst.0 | |
| store i32 %add, ptr %gep.dst.1 | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %ec = icmp eq i64 %iv.next, 1024 | |
| br i1 %ec, label %exit, label %loop | |
| exit: | |
| ret void | |
| } | |
| ; Same as above, but with a reverse store group. | |
| define void @interleave_store_factor_2_reverse(ptr noalias %src, ptr noalias %dst) { | |
| ; CHECK-LABEL: 'interleave_store_factor_2_reverse' | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[VP6:%[0-9]+]]> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%idx.0> = shl nuw nsw vp<[[VP6]]>, ir<1> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.dst.0> = getelementptr inbounds ir<%dst>, ir<%idx.0> | |
| ; CHECK: Cost for VF 2: 11 (Estimated cost per lane: 5.5) | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[VP6]]> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%idx.0> = shl nuw nsw vp<[[VP6]]>, ir<1> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.dst.0> = getelementptr inbounds ir<%dst>, ir<%idx.0> | |
| ; CHECK: Cost for VF 4: 27 (Estimated cost per lane: 6.75) | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.src> = getelementptr inbounds ir<%src>, vp<[[VP6]]> | |
| ; CHECK: Cost of 1 for VF 8: CLONE ir<%idx.0> = shl nuw nsw vp<[[VP6]]>, ir<1> | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.dst.0> = getelementptr inbounds ir<%dst>, ir<%idx.0> | |
| ; CHECK: Cost for VF 8: 53 (Estimated cost per lane: 6.63) | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %iv = phi i64 [ 1023, %entry ], [ %iv.next, %loop ] | |
| %gep.src = getelementptr inbounds i32, ptr %src, i64 %iv | |
| %l = load i32, ptr %gep.src | |
| %add = add i32 %l, 1 | |
| %idx.0 = shl nuw nsw i64 %iv, 1 | |
| %idx.1 = or disjoint i64 %idx.0, 1 | |
| %gep.dst.0 = getelementptr inbounds i32, ptr %dst, i64 %idx.0 | |
| %gep.dst.1 = getelementptr inbounds i32, ptr %dst, i64 %idx.1 | |
| store i32 %l, ptr %gep.dst.0 | |
| store i32 %add, ptr %gep.dst.1 | |
| %iv.next = add nsw i64 %iv, -1 | |
| %ec = icmp eq i64 %iv, 0 | |
| br i1 %ec, label %exit, label %loop | |
| exit: | |
| ret void | |
| } | |
| ; The load group uses the address of member 1, as it is computed first. | |
| define void @interleave_load_factor_2_member_1_first(ptr noalias %src, ptr noalias %dst) { | |
| ; CHECK-LABEL: 'interleave_load_factor_2_member_1_first' | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%iv.shl> = shl nuw nsw vp<[[VP4:%[0-9]+]]>, ir<1> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%idx.1> = or disjoint ir<%iv.shl>, ir<1> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.src.1> = getelementptr inbounds ir<%src>, ir<%idx.1> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost for VF 2: 9 (Estimated cost per lane: 4.5) | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%iv.shl> = shl nuw nsw vp<[[VP4]]>, ir<1> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%idx.1> = or disjoint ir<%iv.shl>, ir<1> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.src.1> = getelementptr inbounds ir<%src>, ir<%idx.1> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost for VF 4: 9 (Estimated cost per lane: 2.25) | |
| ; CHECK: Cost of 0 for VF 8: forced scalar %gep.src.1 = getelementptr inbounds i32, ptr %src, i64 %idx.1 | |
| ; CHECK: Cost of 8 for VF 8: forced scalar %idx.1 = or disjoint i64 %iv.shl, 1 | |
| ; CHECK: Cost of 8 for VF 8: forced scalar %iv.shl = shl nuw nsw i64 %iv, 1 | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost for VF 8: 66 (Estimated cost per lane: 8.25) | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] | |
| %iv.shl = shl nuw nsw i64 %iv, 1 | |
| %idx.1 = or disjoint i64 %iv.shl, 1 | |
| %gep.src.1 = getelementptr inbounds i32, ptr %src, i64 %idx.1 | |
| %l.1 = load i32, ptr %gep.src.1 | |
| %idx.0 = mul nuw nsw i64 %iv, 2 | |
| %gep.src.0 = getelementptr inbounds i32, ptr %src, i64 %idx.0 | |
| %l.0 = load i32, ptr %gep.src.0 | |
| %sub = sub i32 %l.0, %l.1 | |
| %gep.dst = getelementptr inbounds i32, ptr %dst, i64 %iv | |
| store i32 %sub, ptr %gep.dst | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %ec = icmp eq i64 %iv.next, 1024 | |
| br i1 %ec, label %exit, label %loop | |
| exit: | |
| ret void | |
| } | |
| ; The load group uses the address of member 1, as member 0 is dead. | |
| define void @interleave_load_factor_2_dead_member_0(ptr noalias %src, ptr noalias %dst) { | |
| ; CHECK-LABEL: 'interleave_load_factor_2_dead_member_0' | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%iv.shl> = shl nuw nsw vp<[[VP4:%[0-9]+]]>, ir<1> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%idx.1> = or disjoint ir<%iv.shl>, ir<1> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.src.1> = getelementptr inbounds ir<%src>, ir<%idx.1> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost for VF 2: 9 (Estimated cost per lane: 4.5) | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%iv.shl> = shl nuw nsw vp<[[VP4]]>, ir<1> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%idx.1> = or disjoint ir<%iv.shl>, ir<1> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.src.1> = getelementptr inbounds ir<%src>, ir<%idx.1> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost for VF 4: 9 (Estimated cost per lane: 2.25) | |
| ; CHECK: Cost of 0 for VF 8: forced scalar %gep.src.1 = getelementptr inbounds i32, ptr %src, i64 %idx.1 | |
| ; CHECK: Cost of 8 for VF 8: forced scalar %idx.1 = or disjoint i64 %iv.shl, 1 | |
| ; CHECK: Cost of 8 for VF 8: forced scalar %iv.shl = shl nuw nsw i64 %iv, 1 | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.dst> = getelementptr inbounds ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost for VF 8: 41 (Estimated cost per lane: 5.13) | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] | |
| %iv.shl = shl nuw nsw i64 %iv, 1 | |
| %idx.1 = or disjoint i64 %iv.shl, 1 | |
| %gep.src.1 = getelementptr inbounds i32, ptr %src, i64 %idx.1 | |
| %l.1 = load i32, ptr %gep.src.1 | |
| %idx.0 = mul nuw nsw i64 %iv, 2 | |
| %gep.src.0 = getelementptr inbounds i32, ptr %src, i64 %idx.0 | |
| %l.0 = load i32, ptr %gep.src.0 | |
| %add = add i32 %l.1, 1 | |
| %gep.dst = getelementptr inbounds i32, ptr %dst, i64 %iv | |
| store i32 %add, ptr %gep.dst | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %ec = icmp eq i64 %iv.next, 1024 | |
| br i1 %ec, label %exit, label %loop | |
| exit: | |
| ret void | |
| } | |
| ; The invariant offset of the group addresses is hoisted out of the loop. | |
| define void @interleave_load_factor_2_invariant_offset(ptr noalias %src, ptr noalias %dst, i64 %n) { | |
| ; CHECK-LABEL: 'interleave_load_factor_2_invariant_offset' | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%iv.shl> = shl nuw nsw vp<[[VP4:%[0-9]+]]>, ir<1> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%idx.0> = add nuw nsw ir<%iv.shl>, ir<%off.shl> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.src.0> = getelementptr ir<%src>, ir<%idx.0> | |
| ; CHECK: Cost of 0 for VF 2: CLONE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%off> = and ir<%n>, ir<7> | |
| ; CHECK: Cost of 1 for VF 2: CLONE ir<%off.shl> = shl ir<%off>, ir<1> | |
| ; CHECK: Cost for VF 2: 9 (Estimated cost per lane: 4.5) | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%iv.shl> = shl nuw nsw vp<[[VP4]]>, ir<1> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%idx.0> = add nuw nsw ir<%iv.shl>, ir<%off.shl> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.src.0> = getelementptr ir<%src>, ir<%idx.0> | |
| ; CHECK: Cost of 0 for VF 4: CLONE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%off> = and ir<%n>, ir<7> | |
| ; CHECK: Cost of 1 for VF 4: CLONE ir<%off.shl> = shl ir<%off>, ir<1> | |
| ; CHECK: Cost for VF 4: 9 (Estimated cost per lane: 2.25) | |
| ; CHECK: Cost of 0 for VF 8: forced scalar %gep.src.0 = getelementptr i32, ptr %src, i64 %idx.0 | |
| ; CHECK: Cost of 8 for VF 8: forced scalar %idx.0 = add nuw nsw i64 %iv.shl, %off.shl | |
| ; CHECK: Cost of 8 for VF 8: forced scalar %iv.shl = shl nuw nsw i64 %iv, 1 | |
| ; CHECK: Cost of 0 for VF 8: CLONE ir<%gep.dst> = getelementptr ir<%dst>, vp<[[VP4]]> | |
| ; CHECK: Cost of 1 for VF 8: CLONE ir<%off> = and ir<%n>, ir<7> | |
| ; CHECK: Cost of 1 for VF 8: CLONE ir<%off.shl> = shl ir<%off>, ir<1> | |
| ; CHECK: Cost for VF 8: 58 (Estimated cost per lane: 7.25) | |
| ; | |
| entry: | |
| br label %loop | |
| loop: | |
| %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ] | |
| %off = and i64 %n, 7 | |
| %off.shl = shl i64 %off, 1 | |
| %iv.shl = shl nuw nsw i64 %iv, 1 | |
| %idx.0 = add nuw nsw i64 %iv.shl, %off.shl | |
| %idx.1 = add nuw nsw i64 %idx.0, 1 | |
| %gep.src.0 = getelementptr i32, ptr %src, i64 %idx.0 | |
| %gep.src.1 = getelementptr i32, ptr %src, i64 %idx.1 | |
| %l.0 = load i32, ptr %gep.src.0 | |
| %l.1 = load i32, ptr %gep.src.1 | |
| %sub = sub i32 %l.0, %l.1 | |
| %gep.dst = getelementptr i32, ptr %dst, i64 %iv | |
| store i32 %sub, ptr %gep.dst | |
| %iv.next = add nuw nsw i64 %iv, 1 | |
| %ec = icmp eq i64 %iv.next, 1024 | |
| br i1 %ec, label %exit, label %loop | |
| exit: | |
| ret void | |
| } |