Skip to content

Commit a500703

Browse files
committed
[ConstraintElim] Add samesign test. NFC
1 parent 5e26fb1 commit a500703

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

llvm/test/Transforms/ConstraintElimination/transfer-samesign-facts.ll

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,3 +303,45 @@ define i1 @ugt_assumed_positive_values(i8 %a, i8 %b) {
303303

304304
ret i1 %result
305305
}
306+
307+
define i1 @samesign_flipped_signedness_1(i8 %a, i8 %b) {
308+
; CHECK-LABEL: @samesign_flipped_signedness_1(
309+
; CHECK-NEXT: [[CMP_UGT:%.*]] = icmp ugt i8 [[A:%.*]], [[B:%.*]]
310+
; CHECK-NEXT: br i1 [[CMP_UGT]], label [[GREATER:%.*]], label [[EXIT:%.*]]
311+
; CHECK: greater:
312+
; CHECK-NEXT: [[CMP_SGT:%.*]] = icmp samesign sgt i8 [[A]], [[B]]
313+
; CHECK-NEXT: ret i1 [[CMP_SGT]]
314+
; CHECK: exit:
315+
; CHECK-NEXT: ret i1 false
316+
;
317+
%cmp_ugt = icmp ugt i8 %a, %b
318+
br i1 %cmp_ugt, label %greater, label %exit
319+
320+
greater:
321+
%cmp_sgt = icmp samesign sgt i8 %a, %b
322+
ret i1 %cmp_sgt
323+
324+
exit:
325+
ret i1 false
326+
}
327+
328+
define i1 @samesign_flipped_signedness_2(i32 %a) {
329+
; CHECK-LABEL: @samesign_flipped_signedness_2(
330+
; CHECK-NEXT: [[CMP_ULT:%.*]] = icmp samesign ult i32 [[A:%.*]], 65
331+
; CHECK-NEXT: br i1 [[CMP_ULT]], label [[FOR_COND_PREHEADER:%.*]], label [[IF_ELSE:%.*]]
332+
; CHECK: for.cond.preheader:
333+
; CHECK-NEXT: ret i1 false
334+
; CHECK: if.else:
335+
; CHECK-NEXT: [[CMP_UGT:%.*]] = icmp samesign ugt i32 [[A]], -65
336+
; CHECK-NEXT: ret i1 [[CMP_UGT]]
337+
;
338+
%cmp_ult = icmp samesign ult i32 %a, 65
339+
br i1 %cmp_ult, label %for.cond.preheader, label %if.else
340+
341+
for.cond.preheader:
342+
ret i1 false
343+
344+
if.else:
345+
%cmp_ugt = icmp samesign ugt i32 %a, -65
346+
ret i1 %cmp_ugt
347+
}

0 commit comments

Comments
 (0)