Philip Reames 7d6e8f2a96 [slp] Delete dead scalar instructions feeding vectorized instructions
If we vectorize a e.g. store, we leave around a bunch of getelementptrs for the individual scalar stores which we removed. We can go ahead and delete them as well.

This is purely for test output quality and readability. It should have no effect in any sane pipeline.

Differential Revision: https://reviews.llvm.org/D122493
2022-03-28 20:10:13 -07:00

59 lines
2.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; PR23510
; RUN: opt < %s -basic-aa -slp-vectorizer -S | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
@total = global i64 0, align 8
define void @_Z3fooPml(i64* nocapture %a, i64 %i) {
; CHECK-LABEL: @_Z3fooPml(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i64* [[A:%.*]] to <2 x i64>*
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i64>, <2 x i64>* [[TMP0]], align 8
; CHECK-NEXT: [[TMP2:%.*]] = lshr <2 x i64> [[TMP1]], <i64 4, i64 4>
; CHECK-NEXT: [[TMP3:%.*]] = bitcast i64* [[A]] to <2 x i64>*
; CHECK-NEXT: store <2 x i64> [[TMP2]], <2 x i64>* [[TMP3]], align 8
; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i64, i64* [[A]], i64 [[I:%.*]]
; CHECK-NEXT: [[TMP2:%.*]] = load i64, i64* [[ARRAYIDX3]], align 8
; CHECK-NEXT: [[TMP3:%.*]] = load i64, i64* @total, align 8
; CHECK-NEXT: [[ADD:%.*]] = add i64 [[TMP3]], [[TMP2]]
; CHECK-NEXT: store i64 [[ADD]], i64* @total, align 8
; CHECK-NEXT: [[TMP4:%.*]] = bitcast i64* [[A]] to <2 x i64>*
; CHECK-NEXT: [[TMP5:%.*]] = load <2 x i64>, <2 x i64>* [[TMP4]], align 8
; CHECK-NEXT: [[TMP6:%.*]] = lshr <2 x i64> [[TMP5]], <i64 4, i64 4>
; CHECK-NEXT: [[TMP7:%.*]] = bitcast i64* [[A]] to <2 x i64>*
; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64>* [[TMP7]], align 8
; CHECK-NEXT: [[TMP6:%.*]] = load i64, i64* [[ARRAYIDX3]], align 8
; CHECK-NEXT: [[TMP7:%.*]] = load i64, i64* @total, align 8
; CHECK-NEXT: [[ADD9:%.*]] = add i64 [[TMP7]], [[TMP6]]
; CHECK-NEXT: store i64 [[ADD9]], i64* @total, align 8
; CHECK-NEXT: ret void
;
entry:
%tmp = load i64, i64* %a, align 8
%shr = lshr i64 %tmp, 4
store i64 %shr, i64* %a, align 8
%arrayidx1 = getelementptr inbounds i64, i64* %a, i64 1
%tmp1 = load i64, i64* %arrayidx1, align 8
%shr2 = lshr i64 %tmp1, 4
store i64 %shr2, i64* %arrayidx1, align 8
%arrayidx3 = getelementptr inbounds i64, i64* %a, i64 %i
%tmp2 = load i64, i64* %arrayidx3, align 8
%tmp3 = load i64, i64* @total, align 8
%add = add i64 %tmp3, %tmp2
store i64 %add, i64* @total, align 8
%tmp4 = load i64, i64* %a, align 8
%shr5 = lshr i64 %tmp4, 4
store i64 %shr5, i64* %a, align 8
%tmp5 = load i64, i64* %arrayidx1, align 8
%shr7 = lshr i64 %tmp5, 4
store i64 %shr7, i64* %arrayidx1, align 8
%tmp6 = load i64, i64* %arrayidx3, align 8
%tmp7 = load i64, i64* @total, align 8
%add9 = add i64 %tmp7, %tmp6
store i64 %add9, i64* @total, align 8
ret void
}