ComputeMaskedBits: Make knownzero computation more aggressive for ctlz with undef...
[oota-llvm.git] / test / Transforms / InstCombine / sub-xor.ll
1 ; RUN: opt -instcombine -S < %s | FileCheck %s
2
3 define i32 @test1(i32 %x) nounwind {
4   %and = and i32 %x, 31
5   %sub = sub i32 63, %and
6   ret i32 %sub
7
8 ; CHECK: @test1
9 ; CHECK-NEXT: and i32 %x, 31
10 ; CHECK-NEXT: xor i32 %and, 63
11 ; CHECK-NEXT: ret
12 }
13
14 declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
15
16 define i32 @test2(i32 %x) nounwind {
17   %count = tail call i32 @llvm.ctlz.i32(i32 %x, i1 true) nounwind readnone
18   %sub = sub i32 31, %count
19   ret i32 %sub
20
21 ; CHECK: @test2
22 ; CHECK-NEXT: ctlz
23 ; CHECK-NEXT: xor i32 %count, 31
24 ; CHECK-NEXT: ret
25 }