[PATCH] D136726: [SelectionDAGBuilder] use bitcast instead of AnyExtOrTrunc if copy parts from an int vector to a float vector to fix issue #58615
Henry Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 25 18:07:09 PDT 2022
HazyFish created this revision.
Herald added subscribers: ctetreau, hiraditya.
Herald added a project: All.
HazyFish requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The getCopyFromPartsVector doesn't work correctly when PartEVT and ValueVT have both different element type and different size.
This patch
1. removes the part of a comment that contains the incorrect assumption that element type are the same
2. use bitcast when copy parts of int vector to a float vector after the subvector extraction
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D136726
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/AArch64/aarch64-v1f32-arg.ll
Index: llvm/test/CodeGen/AArch64/aarch64-v1f32-arg.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-v1f32-arg.ll
@@ -0,0 +1,11 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=aarch64 | FileCheck %s
+
+define <1 x float> @f(<16 x i64> %0, <1 x float> %1) {
+; CHECK-LABEL: f:
+; CHECK: // %bb.0: // %BB
+; CHECK-NEXT: ldr d0, [sp]
+; CHECK-NEXT: ret
+BB:
+ ret <1 x float> %1
+}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -398,10 +398,9 @@
if (ValueVT.getSizeInBits() == PartEVT.getSizeInBits())
return DAG.getNode(ISD::BITCAST, DL, ValueVT, Val);
- // If the element type of the source/dest vectors are the same, but the
- // parts vector has more elements than the value vector, then we have a
- // vector widening case (e.g. <2 x float> -> <4 x float>). Extract the
- // elements we want.
+ // If the parts vector has more elements than the value vector, then we
+ // have a vector widening case (e.g. <2 x float> -> <4 x float>).
+ // Extract the elements we want.
if (PartEVT.getVectorElementCount() != ValueVT.getVectorElementCount()) {
assert((PartEVT.getVectorElementCount().getKnownMinValue() >
ValueVT.getVectorElementCount().getKnownMinValue()) &&
@@ -415,6 +414,9 @@
DAG.getVectorIdxConstant(0, DL));
if (PartEVT == ValueVT)
return Val;
+
+ if (PartEVT.isInteger() && ValueVT.isFloatingPoint())
+ return DAG.getNode(ISD::BITCAST, DL, ValueVT, Val);
}
// Promoted vector extract
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136726.470665.patch
Type: text/x-patch
Size: 1870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/aa2c051c/attachment.bin>
More information about the llvm-commits
mailing list