Skip to content

Commit 12697c5

Browse files
authored
[LegalizeTypes] Check getTypeAction before calling GetScalarizedVector. (#135838)
Use getTypeAction instead of trying to guess how a type will be legalized. On AArch64, v1f16 is scalarized but v1f16 is widened. Fixes #135776
1 parent f83c5fe commit 12697c5

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,7 @@ SDValue DAGTypeLegalizer::ScalarizeVecRes_MERGE_VALUES(SDNode *N,
400400

401401
SDValue DAGTypeLegalizer::ScalarizeVecRes_BITCAST(SDNode *N) {
402402
SDValue Op = N->getOperand(0);
403-
if (Op.getValueType().isVector()
404-
&& Op.getValueType().getVectorNumElements() == 1
405-
&& !isSimpleLegalType(Op.getValueType()))
403+
if (getTypeAction(Op.getValueType()) == TargetLowering::TypeScalarizeVector)
406404
Op = GetScalarizedVector(Op);
407405
EVT NewVT = N->getValueType(0).getVectorElementType();
408406
return DAG.getNode(ISD::BITCAST, SDLoc(N),

llvm/test/CodeGen/AArch64/pr135776.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
3+
; RUN: llc < %s -mtriple=aarch64-linux-gnu | FileCheck %s
4+
5+
define i32 @bitcast_failure(ptr %0, <1 x i16> %1) {
6+
; CHECK-LABEL: bitcast_failure:
7+
; CHECK: // %bb.0:
8+
; CHECK-NEXT: mov x8, x0
9+
; CHECK-NEXT: mov w0, wzr
10+
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
11+
; CHECK-NEXT: str h0, [x8]
12+
; CHECK-NEXT: ret
13+
%3 = bitcast <1 x i16> %1 to <1 x half>
14+
%4 = extractelement <1 x half> %3, i64 0
15+
store half %4, ptr %0, align 2
16+
ret i32 0
17+
}

0 commit comments

Comments
 (0)