Skip to content

Commit 6bee710

Browse files
committed
pre-commit tests
1 parent 414590b commit 6bee710

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

llvm/test/Transforms/InstCombine/canonicalize-const-to-bop.ll

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,3 +450,82 @@ define i8 @umax_sgt(i8 %x) {
450450
%s = select i1 %cmp, i8 100, i8 %umax
451451
ret i8 %s
452452
}
453+
454+
define i8 @add_sgt_nuw_nsw_safe(i8 %x) {
455+
; CHECK-LABEL: define i8 @add_sgt_nuw_nsw_safe(
456+
; CHECK-SAME: i8 [[X:%.*]]) {
457+
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.smin.i8(i8 [[X]], i8 100)
458+
; CHECK-NEXT: [[S:%.*]] = add nsw i8 [[TMP1]], 1
459+
; CHECK-NEXT: ret i8 [[S]]
460+
;
461+
%add = add nuw nsw i8 %x, 1
462+
%cmp = icmp sgt i8 %x, 100
463+
%s = select i1 %cmp, i8 101, i8 %add
464+
ret i8 %s
465+
}
466+
467+
define i8 @add_sgt_nuw_only(i8 %x) {
468+
; CHECK-LABEL: define i8 @add_sgt_nuw_only(
469+
; CHECK-SAME: i8 [[X:%.*]]) {
470+
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.smin.i8(i8 [[X]], i8 100)
471+
; CHECK-NEXT: [[S:%.*]] = add i8 [[TMP1]], 50
472+
; CHECK-NEXT: ret i8 [[S]]
473+
;
474+
%add = add nuw nsw i8 %x, 50
475+
%cmp = icmp sgt i8 %x, 100
476+
%s = select i1 %cmp, i8 150, i8 %add
477+
ret i8 %s
478+
}
479+
480+
define i8 @add_sgt_nsw_only(i8 %x) {
481+
; CHECK-LABEL: define i8 @add_sgt_nsw_only(
482+
; CHECK-SAME: i8 [[X:%.*]]) {
483+
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.smin.i8(i8 [[X]], i8 100)
484+
; CHECK-NEXT: [[S:%.*]] = add i8 [[TMP1]], -99
485+
; CHECK-NEXT: ret i8 [[S]]
486+
;
487+
%add = add nuw nsw i8 %x, -99
488+
%cmp = icmp sgt i8 %x, 100
489+
%s = select i1 %cmp, i8 1, i8 %add
490+
ret i8 %s
491+
}
492+
493+
494+
define i8 @mul_ult_nuw_nsw_safe(i8 %x) {
495+
; CHECK-LABEL: define i8 @mul_ult_nuw_nsw_safe(
496+
; CHECK-SAME: i8 [[X:%.*]]) {
497+
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 10)
498+
; CHECK-NEXT: [[S:%.*]] = mul i8 [[TMP1]], 3
499+
; CHECK-NEXT: ret i8 [[S]]
500+
;
501+
%mul = mul nuw nsw i8 %x, 3
502+
%cmp = icmp ult i8 %x, 10
503+
%s = select i1 %cmp, i8 30, i8 %mul
504+
ret i8 %s
505+
}
506+
507+
define i8 @mul_ult_nuw_only(i8 %x) {
508+
; CHECK-LABEL: define i8 @mul_ult_nuw_only(
509+
; CHECK-SAME: i8 [[X:%.*]]) {
510+
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 10)
511+
; CHECK-NEXT: [[S:%.*]] = mul i8 [[TMP1]], 25
512+
; CHECK-NEXT: ret i8 [[S]]
513+
;
514+
%mul = mul nuw nsw i8 %x, 25
515+
%cmp = icmp ult i8 %x, 10
516+
%s = select i1 %cmp, i8 250, i8 %mul
517+
ret i8 %s
518+
}
519+
520+
define i8 @mul_ult_nsw_only(i8 %x) {
521+
; CHECK-LABEL: define i8 @mul_ult_nsw_only(
522+
; CHECK-SAME: i8 [[X:%.*]]) {
523+
; CHECK-NEXT: [[TMP1:%.*]] = call i8 @llvm.umax.i8(i8 [[X]], i8 40)
524+
; CHECK-NEXT: [[S:%.*]] = mul i8 [[TMP1]], -2
525+
; CHECK-NEXT: ret i8 [[S]]
526+
;
527+
%mul = mul nuw nsw i8 %x, -2
528+
%cmp = icmp ult i8 %x, 40
529+
%s = select i1 %cmp, i8 -80, i8 %mul
530+
ret i8 %s
531+
}

0 commit comments

Comments
 (0)