| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| ; RUN: opt < %s -slp-vectorizer -S -mtriple=x86_64-apple-macosx10.10.0 -mattr=+sse4.2 | FileCheck %s |
| |
| |
| define i32 @test(i32* nocapture readonly %p) { |
| ; CHECK-LABEL: @test( |
| ; CHECK-NEXT: entry: |
| ; CHECK-NEXT: [[ARRAYIDX_1:%.*]] = getelementptr inbounds i32, i32* [[P:%.*]], i64 1 |
| ; CHECK-NEXT: [[ARRAYIDX_2:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 2 |
| ; CHECK-NEXT: [[ARRAYIDX_3:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 3 |
| ; CHECK-NEXT: [[ARRAYIDX_4:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 4 |
| ; CHECK-NEXT: [[ARRAYIDX_5:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 5 |
| ; CHECK-NEXT: [[ARRAYIDX_6:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 6 |
| ; CHECK-NEXT: [[ARRAYIDX_7:%.*]] = getelementptr inbounds i32, i32* [[P]], i64 7 |
| ; CHECK-NEXT: br label [[FOR_BODY:%.*]] |
| ; CHECK: for.body: |
| ; CHECK-NEXT: [[SUM:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[BIN_EXTRA:%.*]], [[FOR_BODY]] ] |
| ; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[P]] to <8 x i32>* |
| ; CHECK-NEXT: [[TMP1:%.*]] = load <8 x i32>, <8 x i32>* [[TMP0]], align 4 |
| ; CHECK-NEXT: [[TMP2:%.*]] = mul <8 x i32> <i32 42, i32 42, i32 42, i32 42, i32 42, i32 42, i32 42, i32 42>, [[TMP1]] |
| ; CHECK-NEXT: [[ADD:%.*]] = add i32 undef, [[SUM]] |
| ; CHECK-NEXT: [[ADD_1:%.*]] = add i32 undef, [[ADD]] |
| ; CHECK-NEXT: [[ADD_2:%.*]] = add i32 undef, [[ADD_1]] |
| ; CHECK-NEXT: [[ADD_3:%.*]] = add i32 undef, [[ADD_2]] |
| ; CHECK-NEXT: [[ADD_4:%.*]] = add i32 undef, [[ADD_3]] |
| ; CHECK-NEXT: [[ADD_5:%.*]] = add i32 undef, [[ADD_4]] |
| ; CHECK-NEXT: [[ADD_6:%.*]] = add i32 undef, [[ADD_5]] |
| ; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <8 x i32> [[TMP2]], <8 x i32> undef, <8 x i32> <i32 4, i32 5, i32 6, i32 7, i32 undef, i32 undef, i32 undef, i32 undef> |
| ; CHECK-NEXT: [[BIN_RDX:%.*]] = add <8 x i32> [[TMP2]], [[RDX_SHUF]] |
| ; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <8 x i32> [[BIN_RDX]], <8 x i32> undef, <8 x i32> <i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> |
| ; CHECK-NEXT: [[BIN_RDX2:%.*]] = add <8 x i32> [[BIN_RDX]], [[RDX_SHUF1]] |
| ; CHECK-NEXT: [[RDX_SHUF3:%.*]] = shufflevector <8 x i32> [[BIN_RDX2]], <8 x i32> undef, <8 x i32> <i32 1, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef, i32 undef> |
| ; CHECK-NEXT: [[BIN_RDX4:%.*]] = add <8 x i32> [[BIN_RDX2]], [[RDX_SHUF3]] |
| ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <8 x i32> [[BIN_RDX4]], i32 0 |
| ; CHECK-NEXT: [[BIN_EXTRA]] = add i32 [[TMP3]], [[SUM]] |
| ; CHECK-NEXT: [[ADD_7:%.*]] = add i32 undef, [[ADD_6]] |
| ; CHECK-NEXT: br i1 true, label [[FOR_END:%.*]], label [[FOR_BODY]] |
| ; CHECK: for.end: |
| ; CHECK-NEXT: ret i32 [[BIN_EXTRA]] |
| ; |
| entry: |
| %arrayidx.1 = getelementptr inbounds i32, i32* %p, i64 1 |
| %arrayidx.2 = getelementptr inbounds i32, i32* %p, i64 2 |
| %arrayidx.3 = getelementptr inbounds i32, i32* %p, i64 3 |
| %arrayidx.4 = getelementptr inbounds i32, i32* %p, i64 4 |
| %arrayidx.5 = getelementptr inbounds i32, i32* %p, i64 5 |
| %arrayidx.6 = getelementptr inbounds i32, i32* %p, i64 6 |
| %arrayidx.7 = getelementptr inbounds i32, i32* %p, i64 7 |
| br label %for.body |
| |
| for.body: |
| %sum = phi i32 [ 0, %entry ], [ %add.7, %for.body ] |
| %tmp = load i32, i32* %p, align 4 |
| %mul = mul i32 %tmp, 42 |
| %add = add i32 %mul, %sum |
| %tmp5 = load i32, i32* %arrayidx.1, align 4 |
| %mul.1 = mul i32 %tmp5, 42 |
| %add.1 = add i32 %mul.1, %add |
| %tmp6 = load i32, i32* %arrayidx.2, align 4 |
| %mul.2 = mul i32 %tmp6, 42 |
| %add.2 = add i32 %mul.2, %add.1 |
| %tmp7 = load i32, i32* %arrayidx.3, align 4 |
| %mul.3 = mul i32 %tmp7, 42 |
| %add.3 = add i32 %mul.3, %add.2 |
| %tmp8 = load i32, i32* %arrayidx.4, align 4 |
| %mul.4 = mul i32 %tmp8, 42 |
| %add.4 = add i32 %mul.4, %add.3 |
| %tmp9 = load i32, i32* %arrayidx.5, align 4 |
| %mul.5 = mul i32 %tmp9, 42 |
| %add.5 = add i32 %mul.5, %add.4 |
| %tmp10 = load i32, i32* %arrayidx.6, align 4 |
| %mul.6 = mul i32 %tmp10, 42 |
| %add.6 = add i32 %mul.6, %add.5 |
| %tmp11 = load i32, i32* %arrayidx.7, align 4 |
| %mul.7 = mul i32 %tmp11, 42 |
| %add.7 = add i32 %mul.7, %add.6 |
| br i1 true, label %for.end, label %for.body |
| |
| for.end: |
| ret i32 %add.7 |
| } |