1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00
Huihui Zhang 83d6fa0d27 [InstCombine][SVE] Fix InstCombiner::visitAllocaInst for scalable vector.
Summary:
DataLayout::getTypeAllocSize() return TypeSize. For cases where scalable
property doesn't matter (check for zero-sized alloca), we should explicitly
call getKnownMinSize() to avoid implicit type conversion to uint64_t, which is
invalid for scalable vector type.

Reviewers: sdesmalen, efriedma, spatel, apazos

Reviewed By: efriedma

Subscribers: tschuett, hiraditya, rkruppe, psnobl, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D76386
2020-03-18 20:57:14 -07:00

38 lines
1.2 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine -verify < %s | FileCheck %s
define <vscale x 4 x i32> @alloca(<vscale x 4 x i32> %z) {
; CHECK-LABEL: @alloca(
; CHECK-NEXT: ret <vscale x 4 x i32> [[Z:%.*]]
;
%a = alloca <vscale x 4 x i32>
store <vscale x 4 x i32> %z, <vscale x 4 x i32>* %a
%load = load <vscale x 4 x i32>, <vscale x 4 x i32>* %a
ret <vscale x 4 x i32> %load
}
define void @alloca_dead_store(<vscale x 4 x i32> %z) {
; CHECK-LABEL: @alloca_dead_store(
; CHECK-NEXT: ret void
;
%a = alloca <vscale x 4 x i32>
store <vscale x 4 x i32> %z, <vscale x 4 x i32>* %a
ret void
}
declare void @use(...)
define void @alloca_zero_byte_move_first_inst() {
; CHECK-LABEL: @alloca_zero_byte_move_first_inst(
; CHECK-NEXT: [[B:%.*]] = alloca {}, align 8
; CHECK-NEXT: [[A:%.*]] = alloca <vscale x 16 x i8>, align 16
; CHECK-NEXT: call void (...) @use(<vscale x 16 x i8>* nonnull [[A]])
; CHECK-NEXT: call void (...) @use({}* nonnull [[B]])
; CHECK-NEXT: ret void
;
%a = alloca <vscale x 16 x i8>
call void (...) @use( <vscale x 16 x i8>* %a )
%b = alloca { }
call void (...) @use( { }* %b )
ret void
}