2016-06-22 22:00:16 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2014-10-22 03:51:55 +08:00
|
|
|
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
|
|
|
|
|
|
|
define i32 @foo(i32 %x) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @foo(
|
|
|
|
; CHECK-NEXT: [[O:%.*]] = and i32 %x, 1
|
|
|
|
; CHECK-NEXT: [[N:%.*]] = add i32 [[O]], -1
|
|
|
|
; CHECK-NEXT: ret i32 [[N]]
|
|
|
|
;
|
|
|
|
%o = and i32 %x, 1
|
|
|
|
%n = add i32 %o, -1
|
|
|
|
%t = ashr i32 %n, 17
|
|
|
|
ret i32 %t
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_eq_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_eq_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 0, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_eq_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_eq_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 0, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_ashr_eq_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_ashr_eq_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 0, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_ne_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_ne_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 0, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_ne_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_ne_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 0, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_lshr_ne_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_lshr_ne_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr i8 0, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_ashr_ne_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_ashr_ne_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr i8 0, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_eq_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_eq_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 128, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_eq_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_eq_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -128, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_lshr_eq_both_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_lshr_eq_both_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr i8 0, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_ne_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_ne_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 128, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_ne_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_ne_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -128, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_lshr_eq_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_lshr_eq_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr i8 128, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_ashr_eq_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_ashr_eq_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -128, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_lshr_ne_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_lshr_ne_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr i8 128, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_ashr_ne_last_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_ashr_ne_last_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -128, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 0
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @lshr_eq_first_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @lshr_eq_first_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr i8 0, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 2
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ashr_eq_first_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @ashr_eq_first_zero(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr i8 0, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 2
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @lshr_ne_first_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @lshr_ne_first_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr i8 0, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 2
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ashr_ne_first_zero(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @ashr_ne_first_zero(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 0, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 2
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ashr_eq_both_minus1(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @ashr_eq_both_minus1(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -1, %a
|
|
|
|
%cmp = icmp eq i8 %shr, -1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ashr_ne_both_minus1(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @ashr_ne_both_minus1(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -1, %a
|
|
|
|
%cmp = icmp ne i8 %shr, -1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_eq_both_minus1(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_eq_both_minus1(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -1, %a
|
|
|
|
%cmp = icmp eq i8 %shr, -1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_ne_both_minus1(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_ne_both_minus1(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -1, %a
|
|
|
|
%cmp = icmp ne i8 %shr, -1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_eq_opposite_msb(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_eq_opposite_msb(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -128, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_eq_noexactlog(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_eq_noexactlog(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -90, %a
|
|
|
|
%cmp = icmp eq i8 %shr, -30
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_ne_opposite_msb(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_ne_opposite_msb(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -128, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ashr_eq_opposite_msb(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @ashr_eq_opposite_msb(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -128, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @ashr_ne_opposite_msb(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @ashr_ne_opposite_msb(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -128, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 1
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_eq_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_eq_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -2, %a
|
|
|
|
%cmp = icmp eq i8 %shr, -8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_ne_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_ne_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -2, %a
|
|
|
|
%cmp = icmp ne i8 %shr, -8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_ashr_eq_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_ashr_eq_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -2, %a
|
|
|
|
%cmp = icmp eq i8 %shr, -8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_ashr_ne_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_ashr_ne_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 -2, %a
|
|
|
|
%cmp = icmp ne i8 %shr, -8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_eq_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_eq_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 2, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_ne_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_ne_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 2, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_lshr_eq_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_lshr_eq_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr i8 2, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @nonexact_lshr_ne_shift_gt(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @nonexact_lshr_ne_shift_gt(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr i8 2, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 8
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_ashr_ne_noexactlog(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_ne_noexactlog(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = ashr exact i8 -90, %a
|
|
|
|
%cmp = icmp ne i8 %shr, -30
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_eq_noexactlog(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_eq_noexactlog(
|
|
|
|
; CHECK-NEXT: ret i1 false
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 90, %a
|
|
|
|
%cmp = icmp eq i8 %shr, 30
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i1 @exact_lshr_ne_noexactlog(i8 %a) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_ne_noexactlog(
|
|
|
|
; CHECK-NEXT: ret i1 true
|
|
|
|
;
|
|
|
|
%shr = lshr exact i8 90, %a
|
|
|
|
%cmp = icmp ne i8 %shr, 30
|
|
|
|
ret i1 %cmp
|
2014-10-22 03:51:55 +08:00
|
|
|
}
|
2014-11-05 08:59:59 +08:00
|
|
|
|
|
|
|
define i32 @exact_lshr_lowbit(i32 %shiftval) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_lshr_lowbit(
|
|
|
|
; CHECK-NEXT: ret i32 7
|
|
|
|
;
|
2014-11-05 08:59:59 +08:00
|
|
|
%shr = lshr exact i32 7, %shiftval
|
|
|
|
ret i32 %shr
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @exact_ashr_lowbit(i32 %shiftval) {
|
2016-06-22 22:00:16 +08:00
|
|
|
; CHECK-LABEL: @exact_ashr_lowbit(
|
|
|
|
; CHECK-NEXT: ret i32 7
|
|
|
|
;
|
2014-11-05 08:59:59 +08:00
|
|
|
%shr = ashr exact i32 7, %shiftval
|
|
|
|
ret i32 %shr
|
|
|
|
}
|