Skip to content

Commit 88ff56c

Browse files
author
Mon P Wang
committed
Make isScalarToVector to return false if the node is a scalar. This will prevent
DAGCombine from making an illegal transformation of bitcast of a scalar to a vector into a scalar_to_vector. llvm-svn: 119819
1 parent 55964f6 commit 88ff56c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ bool ISD::isScalarToVector(const SDNode *N) {
199199
if (N->getOperand(0).getOpcode() == ISD::UNDEF)
200200
return false;
201201
unsigned NumElems = N->getNumOperands();
202+
if (NumElems == 1)
203+
return false;
202204
for (unsigned i = 1; i < NumElems; ++i) {
203205
SDValue V = N->getOperand(i);
204206
if (V.getOpcode() != ISD::UNDEF)

llvm/test/CodeGen/X86/bc-extract.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; RUN: llc < %s -march=x86-64 -mattr=+sse42 -disable-mmx | FileCheck %s
2+
3+
4+
define float @extractFloat1() nounwind {
5+
entry:
6+
; CHECK: 1065353216
7+
%tmp0 = bitcast <1 x double> <double 0x000000003F800000> to <2 x float>
8+
%tmp1 = extractelement <2 x float> %tmp0, i32 0
9+
ret float %tmp1
10+
}
11+
12+
define float @extractFloat2() nounwind {
13+
entry:
14+
; CHECK: pxor %xmm0, %xmm0
15+
%tmp4 = bitcast <1 x double> <double 0x000000003F800000> to <2 x float>
16+
%tmp5 = extractelement <2 x float> %tmp4, i32 1
17+
ret float %tmp5
18+
}
19+
20+
define i32 @extractInt2() nounwind {
21+
entry:
22+
; CHECK: xorl %eax, %eax
23+
%tmp4 = bitcast <1 x i64> <i64 256> to <2 x i32>
24+
%tmp5 = extractelement <2 x i32> %tmp4, i32 1
25+
ret i32 %tmp5
26+
}
27+

0 commit comments

Comments
 (0)