Skip to content

Commit e778cea

Browse files
committed
Fixing miscompilation
1 parent ab11ff0 commit e778cea

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,9 +1740,13 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
17401740
Constant *CElt = CV->getAggregateElement(i);
17411741
if (isa<ConstantExpr>(CElt))
17421742
continue;
1743+
17431744
// TODO: If a select condition element is undef, we can demand from
17441745
// either side. If one side is known undef, choosing that side would
17451746
// propagate undef.
1747+
if (isa<UndefValue>(CElt))
1748+
continue;
1749+
17461750
if (CElt->isNullValue())
17471751
DemandedLHS.clearBit(i);
17481752
else

llvm/test/Transforms/InstCombine/pr98435.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
define <2 x i1> @pr98435(<2 x i1> %val0) {
55
; CHECK-LABEL: define <2 x i1> @pr98435(
66
; CHECK-SAME: <2 x i1> [[VAL0:%.*]]) {
7-
; CHECK-NEXT: ret <2 x i1> <i1 poison, i1 true>
7+
; CHECK-NEXT: [[VAL3:%.*]] = select <2 x i1> <i1 undef, i1 true>, <2 x i1> <i1 true, i1 true>, <2 x i1> [[VAL0]]
8+
; CHECK-NEXT: ret <2 x i1> [[VAL3]]
89
;
910
%val3 = select <2 x i1> <i1 undef, i1 true>, <2 x i1> <i1 true, i1 true>, <2 x i1> %val0
1011
ret <2 x i1> %val3

0 commit comments

Comments
 (0)