mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[ConstantFold][SVE] Fix constant folding for bitcast.
Do not iterate on scalable vector type in BitCastConstantVector. Continuation work of D70985, D71147. Support for folding bitcast into splat value is kept in D74095, as it depends on D71637. Differential Revision: https://reviews.llvm.org/D71389
This commit is contained in:
parent
844565485c
commit
3f01fba31d
@ -47,6 +47,11 @@ static Constant *BitCastConstantVector(Constant *CV, VectorType *DstTy) {
|
||||
if (CV->isAllOnesValue()) return Constant::getAllOnesValue(DstTy);
|
||||
if (CV->isNullValue()) return Constant::getNullValue(DstTy);
|
||||
|
||||
// Do not iterate on scalable vector. The num of elements is unknown at
|
||||
// compile-time.
|
||||
if (DstTy->isScalable())
|
||||
return nullptr;
|
||||
|
||||
// If this cast changes element count then we can't handle it here:
|
||||
// doing so requires endianness information. This should be handled by
|
||||
// Analysis/ConstantFolding.cpp
|
||||
|
12
test/Analysis/ConstantFolding/bitcast.ll
Normal file
12
test/Analysis/ConstantFolding/bitcast.ll
Normal file
@ -0,0 +1,12 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S -verify | FileCheck %s
|
||||
|
||||
define <vscale x 4 x float> @bitcast_scalable_constant() {
|
||||
; CHECK-LABEL: @bitcast_scalable_constant(
|
||||
; CHECK-NEXT: ret <vscale x 4 x float> bitcast (<vscale x 4 x i32> shufflevector (<vscale x 4 x i32> insertelement (<vscale x 4 x i32> undef, i32 1, i32 0), <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer) to <vscale x 4 x float>)
|
||||
;
|
||||
%i1 = insertelement <vscale x 4 x i32> undef, i32 1, i32 0
|
||||
%i2 = shufflevector <vscale x 4 x i32> %i1, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer
|
||||
%i3 = bitcast <vscale x 4 x i32> %i2 to <vscale x 4 x float>
|
||||
ret <vscale x 4 x float> %i3
|
||||
}
|
Loading…
Reference in New Issue
Block a user