Skip to content

Commit

Permalink
[CVP] Add additional tests for undef check (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Dec 21, 2023
1 parent 3107f31 commit 38c1ff8
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions llvm/test/Transforms/CorrelatedValuePropagation/cond-at-use.ll
Original file line number Diff line number Diff line change
Expand Up @@ -567,3 +567,33 @@ define i16 @cond_value_may_not_well_defined(i16 %x) {
%sel = select i1 %cmp, i16 %and, i16 24
ret i16 %sel
}

define i16 @and_elide_poison_flags(i16 noundef %a) {
; CHECK-LABEL: @and_elide_poison_flags(
; CHECK-NEXT: [[X:%.*]] = add nuw i16 [[A:%.*]], 1
; CHECK-NEXT: [[AND:%.*]] = and i16 [[X]], 7
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X]], 8
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i16 [[AND]], i16 24
; CHECK-NEXT: ret i16 [[SEL]]
;
%x = add nuw i16 %a, 1
%and = and i16 %x, 7
%cmp = icmp ult i16 %x, 8
%sel = select i1 %cmp, i16 %and, i16 24
ret i16 %sel
}

define i16 @and_elide_poison_flags_missing_noundef(i16 %a) {
; CHECK-LABEL: @and_elide_poison_flags_missing_noundef(
; CHECK-NEXT: [[X:%.*]] = add nuw i16 [[A:%.*]], 1
; CHECK-NEXT: [[AND:%.*]] = and i16 [[X]], 7
; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X]], 8
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], i16 [[AND]], i16 24
; CHECK-NEXT: ret i16 [[SEL]]
;
%x = add nuw i16 %a, 1
%and = and i16 %x, 7
%cmp = icmp ult i16 %x, 8
%sel = select i1 %cmp, i16 %and, i16 24
ret i16 %sel
}

0 comments on commit 38c1ff8

Please sign in to comment.