Skip to content

Commit 1bc7458

Browse files
committed
[DAGCombiner] Don't ignore N2's undef elements in foldVSelectOfConstants
1 parent e4f4fad commit 1bc7458

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12535,9 +12535,10 @@ SDValue DAGCombiner::foldVSelectOfConstants(SDNode *N) {
1253512535
for (unsigned i = 0; i != Elts; ++i) {
1253612536
SDValue N1Elt = N1.getOperand(i);
1253712537
SDValue N2Elt = N2.getOperand(i);
12538-
if (N1Elt.isUndef() || N2Elt.isUndef())
12538+
if (N1Elt.isUndef())
1253912539
continue;
12540-
if (N1Elt.getValueType() != N2Elt.getValueType()) {
12540+
// N2 should not contain undef values since it will be reused in the fold.
12541+
if (N2Elt.isUndef() || N1Elt.getValueType() != N2Elt.getValueType()) {
1254112542
AllAddOne = false;
1254212543
AllSubOne = false;
1254312544
break;

llvm/test/CodeGen/X86/vselect-constants.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,12 @@ define i32 @wrong_min_signbits(<2 x i16> %x) {
306306
define i32 @pr129181() {
307307
; SSE-LABEL: pr129181:
308308
; SSE: # %bb.0: # %entry
309+
; SSE-NEXT: xorl %eax, %eax
309310
; SSE-NEXT: retq
310311
;
311312
; AVX-LABEL: pr129181:
312313
; AVX: # %bb.0: # %entry
314+
; AVX-NEXT: xorl %eax, %eax
313315
; AVX-NEXT: retq
314316
entry:
315317
%x = insertelement <4 x i32> zeroinitializer, i32 0, i32 0

0 commit comments

Comments
 (0)