[llvm-commits] [llvm] r147142 - in /llvm/trunk: lib/Analysis/BranchProbabilityInfo.cpp test/Analysis/BranchProbabilityInfo/noreturn.ll

Duncan Sands baldrick at free.fr
Tue Dec 27 02:27:44 PST 2011


Hi Chandler,

> Make the unreachable probability much much heavier. The previous
> probability wouldn't be considered "hot" in some weird loop structures
> or other compounding probability patterns. This makes it much harder to
> confuse, but isn't really a principled fix. I'd actually like it if we
> could model a zero probability, as it would make this much easier to
> reason about. Suggestions for how to do this better are welcome.

a call to a function that only throws an exception will usually be followed
by unreachable.  Would giving unreachable zero probability mean that throwing
the exception is considered to occur with probability zero?  While throwing
exceptions is fairly rare, it does happen.

Ciao, Duncan.

>
> Modified:
>      llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
>      llvm/trunk/test/Analysis/BranchProbabilityInfo/noreturn.ll
>
> Modified: llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp?rev=147142&r1=147141&r2=147142&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp (original)
> +++ llvm/trunk/lib/Analysis/BranchProbabilityInfo.cpp Thu Dec 22 03:26:37 2011
> @@ -65,8 +65,9 @@
>   ///
>   /// This is the weight for a branch not being taken toward a block that
>   /// terminates (eventually) in unreachable. Such a branch is essentially never
> -/// taken.
> -static const uint32_t UR_NONTAKEN_WEIGHT = 1023;
> +/// taken. Set the weight to an absurdly high value so that nested loops don't
> +/// easily subsume it.
> +static const uint32_t UR_NONTAKEN_WEIGHT = 1024*1024 - 1;
>
>   static const uint32_t PH_TAKEN_WEIGHT = 20;
>   static const uint32_t PH_NONTAKEN_WEIGHT = 12;
>
> Modified: llvm/trunk/test/Analysis/BranchProbabilityInfo/noreturn.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/BranchProbabilityInfo/noreturn.ll?rev=147142&r1=147141&r2=147142&view=diff
> ==============================================================================
> --- llvm/trunk/test/Analysis/BranchProbabilityInfo/noreturn.ll (original)
> +++ llvm/trunk/test/Analysis/BranchProbabilityInfo/noreturn.ll Thu Dec 22 03:26:37 2011
> @@ -8,8 +8,8 @@
>   entry:
>     %cond = icmp eq i32 %a, 42
>     br i1 %cond, label %exit, label %abort
> -; CHECK: edge entry ->  exit probability is 1023 / 1024
> -; CHECK: edge entry ->  abort probability is 1 / 1024
> +; CHECK: edge entry ->  exit probability is 1048575 / 1048576
> +; CHECK: edge entry ->  abort probability is 1 / 1048576
>
>   abort:
>     call void @abort() noreturn
> @@ -26,11 +26,11 @@
>                                 i32 2, label %case_b
>                                 i32 3, label %case_c
>                                 i32 4, label %case_d]
> -; CHECK: edge entry ->  exit probability is 1023 / 1027
> -; CHECK: edge entry ->  case_a probability is 1 / 1027
> -; CHECK: edge entry ->  case_b probability is 1 / 1027
> -; CHECK: edge entry ->  case_c probability is 1 / 1027
> -; CHECK: edge entry ->  case_d probability is 1 / 1027
> +; CHECK: edge entry ->  exit probability is 1048575 / 1048579
> +; CHECK: edge entry ->  case_a probability is 1 / 1048579
> +; CHECK: edge entry ->  case_b probability is 1 / 1048579
> +; CHECK: edge entry ->  case_c probability is 1 / 1048579
> +; CHECK: edge entry ->  case_d probability is 1 / 1048579
>
>   case_a:
>     br label %case_b
> @@ -55,8 +55,8 @@
>   entry:
>     %cond1 = icmp eq i32 %a, 42
>     br i1 %cond1, label %exit, label %dom
> -; CHECK: edge entry ->  exit probability is 1023 / 1024
> -; CHECK: edge entry ->  dom probability is 1 / 1024
> +; CHECK: edge entry ->  exit probability is 1048575 / 1048576
> +; CHECK: edge entry ->  dom probability is 1 / 1048576
>
>   dom:
>     %cond2 = icmp ult i32 %a, 42
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list