Skip to content

Commit 4405af5

Browse files
committed
[InstCombine] Add pre-commit tests. NFC.
1 parent 5c3c0a8 commit 4405af5

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,56 @@ if.else:
480480
ret i64 13
481481
}
482482

483+
define i64 @test_icmp_trunc_nuw(i64 %a) {
484+
; CHECK-LABEL: @test_icmp_trunc_nuw(
485+
; CHECK-NEXT: entry:
486+
; CHECK-NEXT: [[CAST:%.*]] = trunc nuw i64 [[A:%.*]] to i32
487+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[CAST]], 0
488+
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
489+
; CHECK: if.then:
490+
; CHECK-NEXT: [[B:%.*]] = and i64 [[A]], 2147483647
491+
; CHECK-NEXT: ret i64 [[B]]
492+
; CHECK: if.else:
493+
; CHECK-NEXT: ret i64 0
494+
;
495+
entry:
496+
%cast = trunc nuw i64 %a to i32
497+
%cmp = icmp sgt i32 %cast, 0
498+
br i1 %cmp, label %if.then, label %if.else
499+
500+
if.then:
501+
%b = and i64 %a, 2147483647
502+
ret i64 %b
503+
504+
if.else:
505+
ret i64 0
506+
}
507+
508+
define i64 @test_icmp_trunc_no_nuw(i64 %a) {
509+
; CHECK-LABEL: @test_icmp_trunc_no_nuw(
510+
; CHECK-NEXT: entry:
511+
; CHECK-NEXT: [[CAST:%.*]] = trunc i64 [[A:%.*]] to i32
512+
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[CAST]], 0
513+
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
514+
; CHECK: if.then:
515+
; CHECK-NEXT: [[B:%.*]] = and i64 [[A]], 2147483647
516+
; CHECK-NEXT: ret i64 [[B]]
517+
; CHECK: if.else:
518+
; CHECK-NEXT: ret i64 0
519+
;
520+
entry:
521+
%cast = trunc i64 %a to i32
522+
%cmp = icmp sgt i32 %cast, 0
523+
br i1 %cmp, label %if.then, label %if.else
524+
525+
if.then:
526+
%b = and i64 %a, 2147483647
527+
ret i64 %b
528+
529+
if.else:
530+
ret i64 0
531+
}
532+
483533
define i1 @test_icmp_or_distjoint(i8 %n, i1 %other) {
484534
; CHECK-LABEL: @test_icmp_or_distjoint(
485535
; CHECK-NEXT: entry:

0 commit comments

Comments
 (0)