1 ; bswap should be constant folded when it is passed a constant argument
3 ; RUN: llc < %s -march=x86 | FileCheck %s
5 declare i16 @llvm.bswap.i16(i16)
7 declare i32 @llvm.bswap.i32(i32)
9 declare i64 @llvm.bswap.i64(i64)
11 define i16 @W(i16 %A) {
14 %Z = call i16 @llvm.bswap.i16( i16 %A ) ; <i16> [#uses=1]
18 define i32 @X(i32 %A) {
21 %Z = call i32 @llvm.bswap.i32( i32 %A ) ; <i32> [#uses=1]
25 define i64 @Y(i64 %A) {
29 %Z = call i64 @llvm.bswap.i64( i64 %A ) ; <i64> [#uses=1]
34 define i32 @test1(i32 %a) nounwind readnone {
38 ; CHECK: shrl $16, %eax
40 %shr3 = and i32 %and, 255
42 %shl = and i32 %and2, 65280
43 %or = or i32 %shr3, %shl
47 define i32 @test2(i32 %a) nounwind readnone {
51 ; CHECK: sarl $16, %eax
53 %shr4 = and i32 %and, 255
55 %or = or i32 %shr4, %and2
56 %sext = shl i32 %or, 16
57 %conv3 = ashr exact i32 %sext, 16