mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-22 10:33:23 +00:00
59764b94a7
Summary: This patch adds constant folding of insertelement instruction to undef value when index operand is constant and is not less than vector size or is undef. InstCombine does not support this case, but I'm happy to add it there also if this change is accepted. Test Plan: Unittests and regression tests for ConstProp pass. Reviewers: majnemer Reviewed By: majnemer Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D9287 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235854 91177308-0d34-0410-b5e6-96231b3b80d8
33 lines
1.1 KiB
LLVM
33 lines
1.1 KiB
LLVM
; RUN: opt < %s -constprop -S | FileCheck %s
|
|
|
|
; CHECK-LABEL: @test1
|
|
define i32 @test1() {
|
|
%A = bitcast i32 2139171423 to float
|
|
%B = insertelement <1 x float> undef, float %A, i32 0
|
|
%C = extractelement <1 x float> %B, i32 0
|
|
%D = bitcast float %C to i32
|
|
ret i32 %D
|
|
; CHECK: ret i32 2139171423
|
|
}
|
|
|
|
; CHECK-LABEL: @insertelement
|
|
define <4 x i64> @insertelement() {
|
|
%vec1 = insertelement <4 x i64> undef, i64 -1, i32 0
|
|
%vec2 = insertelement <4 x i64> %vec1, i64 -2, i32 1
|
|
%vec3 = insertelement <4 x i64> %vec2, i64 -3, i32 2
|
|
%vec4 = insertelement <4 x i64> %vec3, i64 -4, i32 3
|
|
; CHECK: ret <4 x i64> <i64 -1, i64 -2, i64 -3, i64 -4>
|
|
ret <4 x i64> %vec4
|
|
}
|
|
|
|
; CHECK-LABEL: @insertelement_undef
|
|
define <4 x i64> @insertelement_undef() {
|
|
%vec1 = insertelement <4 x i64> undef, i64 -1, i32 0
|
|
%vec2 = insertelement <4 x i64> %vec1, i64 -2, i32 1
|
|
%vec3 = insertelement <4 x i64> %vec2, i64 -3, i32 2
|
|
%vec4 = insertelement <4 x i64> %vec3, i64 -4, i32 3
|
|
%vec5 = insertelement <4 x i64> %vec3, i64 -5, i32 4
|
|
; CHECK: ret <4 x i64> undef
|
|
ret <4 x i64> %vec5
|
|
}
|