Skip to content

Commit 68fb3d5

Browse files
committed
[ConstraintElim] Add test with select where the second op cant be poison.
Extra test for TODO from #75750.
1 parent d3ef867 commit 68fb3d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

llvm/test/Transforms/ConstraintElimination/and-implied-by-operands.ll

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,24 @@ entry:
478478
%and = select i1 %c.1, i1 %c.2, i1 false
479479
ret i1 %and
480480
}
481+
482+
define i1 @and_select_second_implies_first_guaranteed_not_poison(ptr noundef %A, ptr noundef %B) {
483+
; CHECK-LABEL: @and_select_second_implies_first_guaranteed_not_poison(
484+
; CHECK-NEXT: entry:
485+
; CHECK-NEXT: [[C_1:%.*]] = icmp ne ptr [[A:%.*]], [[B:%.*]]
486+
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds ptr, ptr [[B]], i64 -1
487+
; CHECK-NEXT: [[C_2:%.*]] = icmp ugt ptr [[GEP]], [[A]]
488+
; CHECK-NEXT: call void @no_noundef(i1 [[C_2]])
489+
; CHECK-NEXT: [[AND:%.*]] = select i1 [[C_1]], i1 [[C_2]], i1 false
490+
; CHECK-NEXT: ret i1 [[AND]]
491+
;
492+
entry:
493+
%c.1 = icmp ne ptr %A, %B
494+
%gep = getelementptr inbounds ptr, ptr %B, i64 -1
495+
%c.2 = icmp ugt ptr %gep, %A
496+
call void @no_noundef(i1 %c.2)
497+
%and = select i1 %c.1, i1 %c.2, i1 false
498+
ret i1 %and
499+
}
500+
501+
declare void @no_noundef(i1 noundef)

0 commit comments

Comments
 (0)