Skip to content

Commit 5485a90

Browse files
committed
[ConstraintElim] Add a negative test. NFC.
1 parent 268f757 commit 5485a90

File tree

1 file changed

+27
-0
lines changed
  • llvm/test/Transforms/ConstraintElimination

1 file changed

+27
-0
lines changed

llvm/test/Transforms/ConstraintElimination/trunc.ll

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,31 @@ if.else:
182182
ret i1 false
183183
}
184184

185+
; We do not know the sign of %x, so we cannot infer nuw for %ext.
186+
define i1 @test_icmp_ult_trunc_nsw_icmp_trunc_nuw(i64 %x, i32 %y) {
187+
; CHECK-LABEL: define i1 @test_icmp_ult_trunc_nsw_icmp_trunc_nuw(
188+
; CHECK-SAME: i64 [[X:%.*]], i32 [[Y:%.*]]) {
189+
; CHECK-NEXT: [[EXT:%.*]] = trunc nsw i64 [[X]] to i32
190+
; CHECK-NEXT: [[COND:%.*]] = icmp ult i32 [[Y]], [[EXT]]
191+
; CHECK-NEXT: br i1 [[COND]], label %[[IF_THEN:.*]], label %[[IF_ELSE:.*]]
192+
; CHECK: [[IF_THEN]]:
193+
; CHECK-NEXT: [[CONV:%.*]] = zext i32 [[Y]] to i64
194+
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[X]], [[CONV]]
195+
; CHECK-NEXT: ret i1 [[CMP]]
196+
; CHECK: [[IF_ELSE]]:
197+
; CHECK-NEXT: ret i1 false
198+
;
199+
%ext = trunc nsw i64 %x to i32
200+
%cond = icmp ult i32 %y, %ext
201+
br i1 %cond, label %if.then, label %if.else
202+
203+
if.then:
204+
%conv = zext i32 %y to i64
205+
%cmp = icmp eq i64 %x, %conv
206+
ret i1 %cmp
207+
208+
if.else:
209+
ret i1 false
210+
}
211+
185212
declare void @cond()

0 commit comments

Comments
 (0)