• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -instcombine -S < %s | FileCheck %s
2
3define 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
14declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
15
16define 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}
26
27define i32 @test3(i32 %x) nounwind {
28  %and = and i32 %x, 31
29  %sub = xor i32 31, %and
30  %add = add i32 %sub, 42
31  ret i32 %add
32
33; CHECK: @test3
34; CHECK-NEXT: and i32 %x, 31
35; CHECK-NEXT: sub i32 73, %and
36; CHECK-NEXT: ret
37}
38