2016-07-21 01:58:20 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
2011-03-30 06:06:41 +08:00
|
|
|
; RUN: opt -S -instcombine < %s | FileCheck %s
|
|
|
|
|
|
|
|
declare void @foo()
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test1(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @test1(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP2]]
|
|
|
|
;
|
2011-03-30 06:06:41 +08:00
|
|
|
%1 = icmp slt i32 %a, 0
|
|
|
|
%2 = icmp slt i32 %b, 0
|
|
|
|
%or.cond = or i1 %1, %2
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2011-03-30 06:06:41 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test2(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @test2(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, %b
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -1
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP2]]
|
|
|
|
;
|
2011-03-30 06:06:41 +08:00
|
|
|
%1 = icmp sgt i32 %a, -1
|
|
|
|
%2 = icmp sgt i32 %b, -1
|
|
|
|
%or.cond = or i1 %1, %2
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2011-03-30 06:06:41 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test3(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @test3(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, %b
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP2]]
|
|
|
|
;
|
2011-03-30 06:06:41 +08:00
|
|
|
%1 = icmp slt i32 %a, 0
|
|
|
|
%2 = icmp slt i32 %b, 0
|
|
|
|
%or.cond = and i1 %1, %2
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2011-03-30 06:06:41 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test4(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @test4(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = or i32 %a, %b
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp sgt i32 [[TMP1]], -1
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP2]]
|
|
|
|
;
|
2011-03-30 06:06:41 +08:00
|
|
|
%1 = icmp sgt i32 %a, -1
|
|
|
|
%2 = icmp sgt i32 %b, -1
|
|
|
|
%or.cond = and i1 %1, %2
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2011-03-30 06:06:41 +08:00
|
|
|
}
|
2012-01-09 02:32:24 +08:00
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define void @test5(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test5(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: br i1 [[TMP2]], label %if.then, label %if.end
|
|
|
|
;
|
2012-01-09 02:32:24 +08:00
|
|
|
%and = and i32 %a, 134217728
|
|
|
|
%1 = icmp eq i32 %and, 0
|
|
|
|
%2 = icmp sgt i32 %a, -1
|
|
|
|
%or.cond = and i1 %1, %2
|
|
|
|
br i1 %or.cond, label %if.then, label %if.end
|
|
|
|
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
tail call void @foo() nounwind
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define void @test6(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test6(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: br i1 [[TMP2]], label %if.then, label %if.end
|
|
|
|
;
|
2012-01-09 02:32:24 +08:00
|
|
|
%1 = icmp sgt i32 %a, -1
|
|
|
|
%and = and i32 %a, 134217728
|
|
|
|
%2 = icmp eq i32 %and, 0
|
|
|
|
%or.cond = and i1 %1, %2
|
|
|
|
br i1 %or.cond, label %if.then, label %if.end
|
|
|
|
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
tail call void @foo() nounwind
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define void @test7(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test7(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: br i1 [[TMP2]], label %if.end, label %if.then
|
|
|
|
;
|
2012-01-09 02:32:24 +08:00
|
|
|
%and = and i32 %a, 134217728
|
|
|
|
%1 = icmp ne i32 %and, 0
|
|
|
|
%2 = icmp slt i32 %a, 0
|
|
|
|
%or.cond = or i1 %1, %2
|
|
|
|
br i1 %or.cond, label %if.then, label %if.end
|
|
|
|
|
|
|
|
|
|
|
|
if.then:
|
|
|
|
tail call void @foo() nounwind
|
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define void @test8(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test8(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -2013265920
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 0
|
|
|
|
; CHECK-NEXT: br i1 [[TMP2]], label %if.end, label %if.then
|
|
|
|
;
|
2012-01-09 02:32:24 +08:00
|
|
|
%1 = icmp slt i32 %a, 0
|
|
|
|
%and = and i32 %a, 134217728
|
|
|
|
%2 = icmp ne i32 %and, 0
|
|
|
|
%or.cond = or i1 %1, %2
|
|
|
|
br i1 %or.cond, label %if.then, label %if.end
|
|
|
|
|
|
|
|
|
|
|
|
if.then:
|
2016-07-21 01:58:20 +08:00
|
|
|
tail call void @foo()
|
2012-01-09 02:32:24 +08:00
|
|
|
ret void
|
|
|
|
|
|
|
|
if.end:
|
|
|
|
ret void
|
|
|
|
}
|
2012-01-10 01:23:27 +08:00
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test9(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test9(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, -1073741824
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i32 [[TMP1]], 1073741824
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP2]]
|
|
|
|
;
|
2012-01-10 01:23:27 +08:00
|
|
|
%1 = and i32 %a, 1073741824
|
|
|
|
%2 = icmp ne i32 %1, 0
|
|
|
|
%3 = icmp sgt i32 %a, -1
|
|
|
|
%or.cond = and i1 %2, %3
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2012-01-10 01:23:27 +08:00
|
|
|
}
|
2014-02-12 05:09:03 +08:00
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test10(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test10(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i32 %a, 2
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP1]]
|
|
|
|
;
|
2014-02-12 05:09:03 +08:00
|
|
|
%1 = and i32 %a, 2
|
|
|
|
%2 = icmp eq i32 %1, 0
|
|
|
|
%3 = icmp ult i32 %a, 4
|
|
|
|
%or.cond = and i1 %2, %3
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2014-02-12 05:09:03 +08:00
|
|
|
}
|
|
|
|
|
2016-07-21 01:58:20 +08:00
|
|
|
define i1 @test11(i32 %a) {
|
|
|
|
; CHECK-LABEL: @test11(
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %a, 1
|
|
|
|
; CHECK-NEXT: ret i1 [[TMP1]]
|
|
|
|
;
|
2014-02-12 05:09:03 +08:00
|
|
|
%1 = and i32 %a, 2
|
|
|
|
%2 = icmp ne i32 %1, 0
|
|
|
|
%3 = icmp ugt i32 %a, 3
|
|
|
|
%or.cond = or i1 %2, %3
|
2016-07-21 01:58:20 +08:00
|
|
|
ret i1 %or.cond
|
2014-02-12 05:09:03 +08:00
|
|
|
}
|