1 ; RUN: opt -instcombine -S < %s | FileCheck %s
3 define i32 @test1(i32 %x) nounwind {
5 %sub = sub i32 63, %and
9 ; CHECK-NEXT: and i32 %x, 31
10 ; CHECK-NEXT: xor i32 %and, 63
14 declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
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
21 ; CHECK-LABEL: @test2(
23 ; CHECK-NEXT: xor i32 %count, 31
27 define i32 @test3(i32 %x) nounwind {
29 %sub = xor i32 31, %and
30 %add = add i32 %sub, 42
33 ; CHECK-LABEL: @test3(
34 ; CHECK-NEXT: and i32 %x, 31
35 ; CHECK-NEXT: sub nsw i32 73, %and
39 define i32 @test4(i32 %x) nounwind {
40 %sub = xor i32 %x, 2147483648
41 %add = add i32 %sub, 42
44 ; CHECK-LABEL: @test4(
45 ; CHECK-NEXT: add i32 %x, -2147483606