blob: 9d34865be5a2edc7213b64361236ba3fe0d24304 [file] [log] [blame]
Nate Begeman1b0674c2005-08-03 18:27:17 +00001; All of these ands and shifts should be folded into rlwimi's
Tanya Lattnercfab3da2008-02-19 08:07:33 +00002; RUN: llvm-as < %s | llc -march=ppc32 -o %t -f
3; RUN: not grep and %t
4; RUN: not grep srawi %t
5; RUN: not grep srwi %t
6; RUN: not grep slwi %t
Dan Gohman28beeea2007-08-15 13:36:28 +00007; RUN: grep rlwinm %t | count 8
Nate Begeman1b0674c2005-08-03 18:27:17 +00008
Tanya Lattnercfab3da2008-02-19 08:07:33 +00009define i32 @test1(i32 %a) {
Nate Begeman1b0674c2005-08-03 18:27:17 +000010entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000011 %tmp.1 = and i32 %a, 268431360 ; <i32> [#uses=1]
12 ret i32 %tmp.1
Nate Begeman1b0674c2005-08-03 18:27:17 +000013}
14
Tanya Lattnercfab3da2008-02-19 08:07:33 +000015define i32 @test2(i32 %a) {
Nate Begeman1b0674c2005-08-03 18:27:17 +000016entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000017 %tmp.1 = and i32 %a, -268435441 ; <i32> [#uses=1]
18 ret i32 %tmp.1
Nate Begeman1b0674c2005-08-03 18:27:17 +000019}
Chris Lattner645f3812005-08-09 20:24:16 +000020
Tanya Lattnercfab3da2008-02-19 08:07:33 +000021define i32 @test3(i32 %a) {
Chris Lattner645f3812005-08-09 20:24:16 +000022entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000023 %tmp.2 = ashr i32 %a, 8 ; <i32> [#uses=1]
24 %tmp.3 = and i32 %tmp.2, 255 ; <i32> [#uses=1]
25 ret i32 %tmp.3
Chris Lattner645f3812005-08-09 20:24:16 +000026}
27
Tanya Lattnercfab3da2008-02-19 08:07:33 +000028define i32 @test4(i32 %a) {
Chris Lattner645f3812005-08-09 20:24:16 +000029entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000030 %tmp.3 = lshr i32 %a, 8 ; <i32> [#uses=1]
31 %tmp.4 = and i32 %tmp.3, 255 ; <i32> [#uses=1]
32 ret i32 %tmp.4
Chris Lattner645f3812005-08-09 20:24:16 +000033}
34
Tanya Lattnercfab3da2008-02-19 08:07:33 +000035define i32 @test5(i32 %a) {
Chris Lattner645f3812005-08-09 20:24:16 +000036entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000037 %tmp.2 = shl i32 %a, 8 ; <i32> [#uses=1]
38 %tmp.3 = and i32 %tmp.2, -8388608 ; <i32> [#uses=1]
39 ret i32 %tmp.3
Chris Lattner645f3812005-08-09 20:24:16 +000040}
41
Tanya Lattnercfab3da2008-02-19 08:07:33 +000042define i32 @test6(i32 %a) {
Chris Lattner645f3812005-08-09 20:24:16 +000043entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000044 %tmp.1 = and i32 %a, 65280 ; <i32> [#uses=1]
45 %tmp.2 = ashr i32 %tmp.1, 8 ; <i32> [#uses=1]
46 ret i32 %tmp.2
Chris Lattner645f3812005-08-09 20:24:16 +000047}
48
Tanya Lattnercfab3da2008-02-19 08:07:33 +000049define i32 @test7(i32 %a) {
Chris Lattner645f3812005-08-09 20:24:16 +000050entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000051 %tmp.1 = and i32 %a, 65280 ; <i32> [#uses=1]
52 %tmp.2 = lshr i32 %tmp.1, 8 ; <i32> [#uses=1]
53 ret i32 %tmp.2
Chris Lattner645f3812005-08-09 20:24:16 +000054}
55
Tanya Lattnercfab3da2008-02-19 08:07:33 +000056define i32 @test8(i32 %a) {
Chris Lattner645f3812005-08-09 20:24:16 +000057entry:
Tanya Lattnercfab3da2008-02-19 08:07:33 +000058 %tmp.1 = and i32 %a, 16711680 ; <i32> [#uses=1]
59 %tmp.2 = shl i32 %tmp.1, 8 ; <i32> [#uses=1]
60 ret i32 %tmp.2
Chris Lattner645f3812005-08-09 20:24:16 +000061}