[PATCH] D17940: SelectionDAG: Fix a crash on inline asm when output register supports multiple types
Tom Stellard via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 13:48:33 PST 2016
tstellarAMD created this revision.
tstellarAMD added reviewers: arsenm, echristo.
tstellarAMD added a subscriber: llvm-commits.
The code in SelectionDAG did not handle the case where the
register type and output types were different, but had the same size.
http://reviews.llvm.org/D17940
Files:
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
test/CodeGen/AMDGPU/inline-asm.ll
Index: test/CodeGen/AMDGPU/inline-asm.ll
===================================================================
--- test/CodeGen/AMDGPU/inline-asm.ll
+++ test/CodeGen/AMDGPU/inline-asm.ll
@@ -39,3 +39,15 @@
endif:
ret void
}
+
+; CHECK: {{^}}v_cmp_asm:
+; CHECK: v_mov_b32_e32 [[SRC:v[0-9]+]], s{{[0-9]+}}
+; CHECK: v_cmp_ne_i32_e64 s{{\[}}[[MASK_LO:[0-9]+]]:[[MASK_HI:[0-9]+]]{{\]}}, 0, [[SRC]]
+; CHECK-DAG: v_mov_b32_e32 v[[V_LO:[0-9]+]], s[[MASK_LO]]
+; CHECK-DAG: v_mov_b32_e32 v[[V_HI:[0-9]+]], s[[MASK_HI]]
+; CHECK: buffer_store_dwordx2 v{{\[}}[[V_LO]]:[[V_HI]]{{\]}}
+define void @v_cmp_asm(i64 addrspace(1)* %out, i32 %in) {
+ %sgpr = tail call i64 asm "v_cmp_ne_i32_e64 $0, 0, $1", "=s,v"(i32 %in)
+ store i64 %sgpr, i64 addrspace(1)* %out
+ ret void
+}
Index: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -208,6 +208,9 @@
Val = DAG.getNode(ISD::TRUNCATE, DL, PartEVT, Val);
}
+ if (PartEVT.getSizeInBits() == ValueVT.getSizeInBits())
+ return DAG.getNode(ISD::BITCAST, DL, ValueVT, Val);
+
if (PartEVT.isInteger() && ValueVT.isInteger()) {
if (ValueVT.bitsLT(PartEVT)) {
// For a truncate, see if we have any information to
@@ -231,9 +234,6 @@
return DAG.getNode(ISD::FP_EXTEND, DL, ValueVT, Val);
}
- if (PartEVT.getSizeInBits() == ValueVT.getSizeInBits())
- return DAG.getNode(ISD::BITCAST, DL, ValueVT, Val);
-
llvm_unreachable("Unknown mismatch!");
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17940.49993.patch
Type: text/x-patch
Size: 1602 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160307/42c12b6d/attachment.bin>
More information about the llvm-commits
mailing list