Skip to content

Commit

Permalink
Fixing miscompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
jf-botto committed Aug 6, 2024
1 parent ab11ff0 commit e778cea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1740,9 +1740,13 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
Constant *CElt = CV->getAggregateElement(i);
if (isa<ConstantExpr>(CElt))
continue;

// TODO: If a select condition element is undef, we can demand from
// either side. If one side is known undef, choosing that side would
// propagate undef.
if (isa<UndefValue>(CElt))
continue;

if (CElt->isNullValue())
DemandedLHS.clearBit(i);
else
Expand Down
3 changes: 2 additions & 1 deletion llvm/test/Transforms/InstCombine/pr98435.ll
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
define <2 x i1> @pr98435(<2 x i1> %val0) {
; CHECK-LABEL: define <2 x i1> @pr98435(
; CHECK-SAME: <2 x i1> [[VAL0:%.*]]) {
; CHECK-NEXT: ret <2 x i1> <i1 poison, i1 true>
; CHECK-NEXT: [[VAL3:%.*]] = select <2 x i1> <i1 undef, i1 true>, <2 x i1> <i1 true, i1 true>, <2 x i1> [[VAL0]]
; CHECK-NEXT: ret <2 x i1> [[VAL3]]
;
%val3 = select <2 x i1> <i1 undef, i1 true>, <2 x i1> <i1 true, i1 true>, <2 x i1> %val0
ret <2 x i1> %val3
Expand Down

0 comments on commit e778cea

Please sign in to comment.