blob: aba2b1b31cce2f10a94c45c3d08c5e286515aa05 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
; RUN: opt -S -passes=slp-vectorizer -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
define i32 @sum_bytes_of_load(ptr %src) {
; CHECK-LABEL: define i32 @sum_bytes_of_load(
; CHECK-SAME: ptr [[SRC:%.*]]) {
; CHECK-NEXT: [[X:%.*]] = load i32, ptr [[SRC]], align 4
; CHECK-NEXT: [[TMP1:%.*]] = bitcast i32 [[X]] to <4 x i8>
; CHECK-NEXT: [[TMP2:%.*]] = zext <4 x i8> [[TMP1]] to <4 x i32>
; CHECK-NEXT: [[TMP3:%.*]] = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> [[TMP2]])
; CHECK-NEXT: ret i32 [[TMP3]]
;
%x = load i32, ptr %src, align 4
%b3 = lshr i32 %x, 24
%s2 = lshr i32 %x, 16
%b2 = and i32 %s2, 255
%s1 = lshr i32 %x, 8
%b1 = and i32 %s1, 255
%b0 = and i32 %x, 255
%a1 = add nuw nsw i32 %b0, %b1
%a2 = add nuw nsw i32 %a1, %b2
%a3 = add nuw nsw i32 %a2, %b3
ret i32 %a3
}