[PATCH] D12341: add llvm.unpredictable intrinsic and lower it to metadata

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 15:59:23 PDT 2015


----- Original Message -----
> From: "Kevin B. Smith" <kevin.b.smith at intel.com>
> To: spatel at rotateright.com, chandlerc at gmail.com, kparzysz at codeaurora.org, hfinkel at anl.gov, "bob wilson"
> <bob.wilson at apple.com>, kubastaszak at gmail.com
> Cc: "kevin b smith" <kevin.b.smith at intel.com>, llvm-commits at lists.llvm.org
> Sent: Thursday, August 27, 2015 5:13:48 PM
> Subject: Re: [PATCH] D12341: add llvm.unpredictable intrinsic and lower it to metadata
> 
> kbsmith1 added a comment.
> 
> No, I am not suggesting you have more history.  I am suggesting that
> you only have a single number that represents the percentage of time
> that the direction is mispredicted.  It would make a lot of sense
> for it to be a simple 0-100 value, and would represent the
> percentage of mispredictions. Anything else takes more space, and is
> much too closely tied to the branch predictor.

I agree.

>From a profiling perspective, we can likely extract this number from sampling (on modern Intel cores, for example, this information is recorded in the MSR_LASTBRANCH_x_FROM_IP MSR (read using RDPMC, etc.), and in the BTS if enabled). I doubt we can efficiently capture anything more.

In practice, as with the profiling data, we might want to store two numbers so that we can store raw sample counts from both sides of a branch without worrying about rescaling. I don't have a strong opinion here.

 -Hal

> 
> ABAB can be perfectly predicted often, AABB can be perfectly
> predicted often. The number of transitions from true to false or
> vice-versa has a poor
> correlation to branch predictability, just as the branch probability
> has a poor correlation to branch predictability.
> 
> 
> http://reviews.llvm.org/D12341
> 
> 
> 
> 

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory


More information about the llvm-commits mailing list