[LLVM][SimplifyCFG] Make validLookupTableConstant explicitly reject vector types. (#182555)
validLookupTableConstant indirectly rejects vectors through its selection of supported Constant classes. However, this is not sufficient when ContantInt/FP are used to represent constant vector splats and so I've added an explicit bailout.
This commit is contained in:
parent
1a81673922
commit
e8d8f8cfcc
@ -6324,6 +6324,9 @@ static bool validLookupTableConstant(Constant *C, const TargetTransformInfo &TTI
|
||||
!isa<UndefValue>(C) && !isa<ConstantExpr>(C))
|
||||
return false;
|
||||
|
||||
if (C->getType()->isVectorTy())
|
||||
return false;
|
||||
|
||||
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
|
||||
// Pointer casts and in-bounds GEPs will not prohibit the backend from
|
||||
// materializing the array of constants.
|
||||
|
||||
@ -0,0 +1,47 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
|
||||
; RUN: opt -passes='simplifycfg<switch-to-lookup>' -S < %s | FileCheck %s
|
||||
; RUN: opt -passes='simplifycfg<switch-to-lookup>' -use-constant-fp-for-fixed-length-splat -S < %s | FileCheck %s
|
||||
|
||||
target triple = "aarch64-unknown-linux-gnu"
|
||||
|
||||
define <4 x float> @no_switch_to_lookup_table_vector_splat(i32 %c) {
|
||||
; CHECK-LABEL: define <4 x float> @no_switch_to_lookup_table_vector_splat(
|
||||
; CHECK-SAME: i32 [[C:%.*]]) {
|
||||
; CHECK-NEXT: [[ENTRY:.*]]:
|
||||
; CHECK-NEXT: switch i32 [[C]], label %[[DEFAULT:.*]] [
|
||||
; CHECK-NEXT: i32 0, label %[[RET:.*]]
|
||||
; CHECK-NEXT: i32 1, label %[[BB1:.*]]
|
||||
; CHECK-NEXT: i32 2, label %[[BB2:.*]]
|
||||
; CHECK-NEXT: ]
|
||||
; CHECK: [[BB1]]:
|
||||
; CHECK-NEXT: br label %[[RET]]
|
||||
; CHECK: [[BB2]]:
|
||||
; CHECK-NEXT: br label %[[RET]]
|
||||
; CHECK: [[DEFAULT]]:
|
||||
; CHECK-NEXT: unreachable
|
||||
; CHECK: [[RET]]:
|
||||
; CHECK-NEXT: [[PHI:%.*]] = phi <4 x float> [ splat (float 3.000000e+00), %[[BB2]] ], [ splat (float 2.000000e+00), %[[BB1]] ], [ splat (float 1.000000e+00), %[[ENTRY]] ]
|
||||
; CHECK-NEXT: ret <4 x float> [[PHI]]
|
||||
entry:
|
||||
switch i32 %c, label %default [
|
||||
i32 0, label %bb0
|
||||
i32 1, label %bb1
|
||||
i32 2, label %bb2
|
||||
]
|
||||
|
||||
bb0:
|
||||
br label %ret
|
||||
|
||||
bb1:
|
||||
br label %ret
|
||||
|
||||
bb2:
|
||||
br label %ret
|
||||
|
||||
default:
|
||||
unreachable
|
||||
|
||||
ret:
|
||||
%phi = phi <4 x float> [ splat (float 1.0), %bb0 ], [ splat (float 2.0), %bb1 ], [ splat (float 3.0), %bb2 ]
|
||||
ret <4 x float> %phi
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user