xref: /llvm-project/llvm/test/Transforms/CodeGenPrepare/ARM/bitreverse-recognize.ll (revision 4ab3041acbdc274050d6c53f72619c7455cbc97a)
1cee313d2SEric Christopher; RUN: opt -S -loop-unroll -codegenprepare < %s | FileCheck %s
2cee313d2SEric Christopher
3cee313d2SEric Christophertarget datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
4cee313d2SEric Christophertarget triple = "armv7--linux-gnueabihf"
5cee313d2SEric Christopher
6cee313d2SEric Christopher; CHECK-LABEL: @f
7cee313d2SEric Christopherdefine i32 @f(i32 %a) #0 {
8cee313d2SEric Christopher; CHECK: call i32 @llvm.bitreverse.i32
9cee313d2SEric Christopherentry:
10cee313d2SEric Christopher  br label %for.body
11cee313d2SEric Christopher
12cee313d2SEric Christopherfor.cond.cleanup:                                 ; preds = %for.body
13cee313d2SEric Christopher  ret i32 %or
14cee313d2SEric Christopher
15cee313d2SEric Christopherfor.body:                                         ; preds = %for.body, %entry
16cee313d2SEric Christopher  %i.08 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
17cee313d2SEric Christopher  %b.07 = phi i32 [ 0, %entry ], [ %or, %for.body ]
18cee313d2SEric Christopher  %shr = lshr i32 %a, %i.08
19cee313d2SEric Christopher  %and = and i32 %shr, 1
20cee313d2SEric Christopher  %sub = sub nuw nsw i32 31, %i.08
21cee313d2SEric Christopher  %shl = shl i32 %and, %sub
22cee313d2SEric Christopher  %or = or i32 %shl, %b.07
23cee313d2SEric Christopher  %inc = add nuw nsw i32 %i.08, 1
24cee313d2SEric Christopher  %exitcond = icmp eq i32 %inc, 32
25cee313d2SEric Christopher  br i1 %exitcond, label %for.cond.cleanup, label %for.body, !llvm.loop !3
26cee313d2SEric Christopher}
27cee313d2SEric Christopher
28*4ab3041aSserge-sans-pailleattributes #0 = { norecurse nounwind readnone "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-a8" "target-features"="+dsp,+neon,+vfp3" "unsafe-fp-math"="false" "use-soft-float"="false" }
29cee313d2SEric Christopher
30cee313d2SEric Christopher!llvm.module.flags = !{!0, !1}
31cee313d2SEric Christopher!llvm.ident = !{!2}
32cee313d2SEric Christopher
33cee313d2SEric Christopher!0 = !{i32 1, !"wchar_size", i32 4}
34cee313d2SEric Christopher!1 = !{i32 1, !"min_enum_size", i32 4}
35cee313d2SEric Christopher!2 = !{!"clang version 3.8.0"}
36cee313d2SEric Christopher!3 = distinct !{!3, !4}
37cee313d2SEric Christopher!4 = !{!"llvm.loop.unroll.full"}
38