2010-01-19 05:55:43 +08:00
|
|
|
; RUN: opt < %s -instcombine -S | FileCheck %s
|
|
|
|
|
|
|
|
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128:n8:16:32:64"
|
2005-09-25 07:42:18 +08:00
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test1(i32 %x) {
|
|
|
|
%tmp.1 = and i32 %x, 65535 ; <i32> [#uses=1]
|
|
|
|
%tmp.2 = xor i32 %tmp.1, -32768 ; <i32> [#uses=1]
|
|
|
|
%tmp.3 = add i32 %tmp.2, 32768 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.3
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test1(
|
2010-01-31 12:29:12 +08:00
|
|
|
; CHECK: %sext = shl i32 %x, 16
|
2011-02-10 13:36:31 +08:00
|
|
|
; CHECK: %tmp.3 = ashr exact i32 %sext, 16
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: ret i32 %tmp.3
|
2005-09-25 07:42:18 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test2(i32 %x) {
|
|
|
|
%tmp.1 = and i32 %x, 65535 ; <i32> [#uses=1]
|
|
|
|
%tmp.2 = xor i32 %tmp.1, 32768 ; <i32> [#uses=1]
|
|
|
|
%tmp.3 = add i32 %tmp.2, -32768 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.3
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test2(
|
2010-01-31 12:29:12 +08:00
|
|
|
; CHECK: %sext = shl i32 %x, 16
|
2011-02-10 13:36:31 +08:00
|
|
|
; CHECK: %tmp.3 = ashr exact i32 %sext, 16
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: ret i32 %tmp.3
|
2005-09-25 07:42:18 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test3(i16 %P) {
|
|
|
|
%tmp.1 = zext i16 %P to i32 ; <i32> [#uses=1]
|
|
|
|
%tmp.4 = xor i32 %tmp.1, 32768 ; <i32> [#uses=1]
|
|
|
|
%tmp.5 = add i32 %tmp.4, -32768 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.5
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test3(
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: %tmp.5 = sext i16 %P to i32
|
|
|
|
; CHECK: ret i32 %tmp.5
|
2005-09-25 07:42:18 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test4(i16 %P) {
|
|
|
|
%tmp.1 = zext i16 %P to i32 ; <i32> [#uses=1]
|
|
|
|
%tmp.4 = xor i32 %tmp.1, 32768 ; <i32> [#uses=1]
|
|
|
|
%tmp.5 = add i32 %tmp.4, -32768 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.5
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test4(
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: %tmp.5 = sext i16 %P to i32
|
|
|
|
; CHECK: ret i32 %tmp.5
|
2005-09-25 07:42:18 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test5(i32 %x) {
|
2010-01-19 05:55:43 +08:00
|
|
|
%tmp.1 = and i32 %x, 255 ; <i32> [#uses=1]
|
2008-03-01 17:15:35 +08:00
|
|
|
%tmp.2 = xor i32 %tmp.1, 128 ; <i32> [#uses=1]
|
|
|
|
%tmp.3 = add i32 %tmp.2, -128 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.3
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test5(
|
2010-01-31 12:29:12 +08:00
|
|
|
; CHECK: %sext = shl i32 %x, 24
|
2011-02-10 13:36:31 +08:00
|
|
|
; CHECK: %tmp.3 = ashr exact i32 %sext, 24
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: ret i32 %tmp.3
|
2005-09-25 07:42:18 +08:00
|
|
|
}
|
|
|
|
|
2008-03-01 17:15:35 +08:00
|
|
|
define i32 @test6(i32 %x) {
|
|
|
|
%tmp.2 = shl i32 %x, 16 ; <i32> [#uses=1]
|
|
|
|
%tmp.4 = ashr i32 %tmp.2, 16 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.4
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test6(
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: %tmp.2 = shl i32 %x, 16
|
2011-02-10 13:36:31 +08:00
|
|
|
; CHECK: %tmp.4 = ashr exact i32 %tmp.2, 16
|
2010-01-19 05:55:43 +08:00
|
|
|
; CHECK: ret i32 %tmp.4
|
2005-09-25 07:42:18 +08:00
|
|
|
}
|
2008-03-01 17:15:35 +08:00
|
|
|
|
2010-01-19 06:19:16 +08:00
|
|
|
define i32 @test7(i16 %P) {
|
|
|
|
%tmp.1 = zext i16 %P to i32 ; <i32> [#uses=1]
|
|
|
|
%sext1 = shl i32 %tmp.1, 16 ; <i32> [#uses=1]
|
|
|
|
%tmp.5 = ashr i32 %sext1, 16 ; <i32> [#uses=1]
|
|
|
|
ret i32 %tmp.5
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test7(
|
2010-01-19 06:19:16 +08:00
|
|
|
; CHECK: %tmp.5 = sext i16 %P to i32
|
|
|
|
; CHECK: ret i32 %tmp.5
|
|
|
|
}
|
2010-01-31 12:29:12 +08:00
|
|
|
|
|
|
|
define i32 @test8(i32 %x) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%shr = lshr i32 %x, 5 ; <i32> [#uses=1]
|
|
|
|
%xor = xor i32 %shr, 67108864 ; <i32> [#uses=1]
|
|
|
|
%sub = add i32 %xor, -67108864 ; <i32> [#uses=1]
|
|
|
|
ret i32 %sub
|
2013-07-14 09:42:54 +08:00
|
|
|
; CHECK-LABEL: @test8(
|
2012-12-04 08:04:54 +08:00
|
|
|
; CHECK: %sub = ashr i32 %x, 5
|
|
|
|
; CHECK: ret i32 %sub
|
2010-01-31 12:29:12 +08:00
|
|
|
}
|