2016-03-26 02:03:17 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by update_test_checks.py
|
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
2008-12-01 09:07:11 +08:00
|
|
|
|
2016-03-26 02:03:17 +08:00
|
|
|
define i32 @func1(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @func1(
|
2016-04-06 01:24:54 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b
|
|
|
|
; CHECK-NEXT: ret i32 [[TMP3]]
|
2016-03-26 02:03:17 +08:00
|
|
|
;
|
2016-04-06 01:24:54 +08:00
|
|
|
%tmp = or i32 %b, %a
|
|
|
|
%tmp1 = and i32 %tmp, 1
|
|
|
|
%tmp2 = and i32 %b, -2
|
|
|
|
%tmp3 = or i32 %tmp1, %tmp2
|
|
|
|
ret i32 %tmp3
|
2008-12-01 09:07:11 +08:00
|
|
|
}
|
|
|
|
|
2016-03-26 02:03:17 +08:00
|
|
|
define i32 @func2(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @func2(
|
2016-04-06 01:24:54 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b
|
|
|
|
; CHECK-NEXT: ret i32 [[TMP3]]
|
2016-03-26 02:03:17 +08:00
|
|
|
;
|
2016-04-06 01:24:54 +08:00
|
|
|
%tmp = or i32 %a, %b
|
|
|
|
%tmp1 = and i32 1, %tmp
|
|
|
|
%tmp2 = and i32 -2, %b
|
|
|
|
%tmp3 = or i32 %tmp1, %tmp2
|
|
|
|
ret i32 %tmp3
|
2008-12-01 09:07:11 +08:00
|
|
|
}
|
|
|
|
|
2016-03-26 02:03:17 +08:00
|
|
|
define i32 @func3(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @func3(
|
2016-04-06 01:24:54 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b
|
|
|
|
; CHECK-NEXT: ret i32 [[TMP3]]
|
2016-03-26 02:03:17 +08:00
|
|
|
;
|
2016-04-06 01:24:54 +08:00
|
|
|
%tmp = or i32 %b, %a
|
|
|
|
%tmp1 = and i32 %tmp, 1
|
|
|
|
%tmp2 = and i32 %b, -2
|
|
|
|
%tmp3 = or i32 %tmp2, %tmp1
|
|
|
|
ret i32 %tmp3
|
2008-12-01 09:07:11 +08:00
|
|
|
}
|
|
|
|
|
2016-03-26 02:03:17 +08:00
|
|
|
define i32 @func4(i32 %a, i32 %b) {
|
|
|
|
; CHECK-LABEL: @func4(
|
2016-04-06 01:24:54 +08:00
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = and i32 %a, 1
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = or i32 [[TMP1]], %b
|
|
|
|
; CHECK-NEXT: ret i32 [[TMP3]]
|
2016-03-26 02:03:17 +08:00
|
|
|
;
|
2016-04-06 01:24:54 +08:00
|
|
|
%tmp = or i32 %a, %b
|
|
|
|
%tmp1 = and i32 1, %tmp
|
|
|
|
%tmp2 = and i32 -2, %b
|
|
|
|
%tmp3 = or i32 %tmp2, %tmp1
|
|
|
|
ret i32 %tmp3
|
2008-12-01 09:07:11 +08:00
|
|
|
}
|
2016-04-06 01:24:54 +08:00
|
|
|
|