[test] Make bt_order_by_weight in switch.ll more robust
authorArthur Eubanks <aeubanks@google.com>
Tue, 27 Oct 2020 22:47:59 +0000 (15:47 -0700)
committerArthur Eubanks <aeubanks@google.com>
Wed, 28 Oct 2020 19:56:23 +0000 (12:56 -0700)
commit3b2256a41b062ff5e9dcf52a99b945cadf2388d1
tree739c014478303f7beb289223232bb21004b33ca4
parent0661328d7efb81a8ac7f2ca0734a65f9be105f29
[test] Make bt_order_by_weight in switch.ll more robust

    Branch weights are not represented internally linearly with the value in
    the IR. In its current state the test happened to pass, but the branch
    weights for 0,3,6 and 2,5,8,9 were not actually equal.

    $ opt -passes='print<branch-prob>'

    shows that the sum of the branch probabilities going to bb0 and bb2 were not the same.

    Printing analysis results of BPI for function 'bt_order_by_weight':
    ---- Branch Probabilities ----
      edge entry -> bb0 probability is 0x00000003 / 0x80000000 = 0.00%
      edge entry -> bb2 probability is 0x00000004 / 0x80000000 = 0.00%

    with this change:

    Printing analysis results of BPI for function 'bt_order_by_weight':
    ---- Branch Probabilities ----
      edge entry -> bb0 probability is 0x00000004 / 0x80000000 = 0.00%
      edge entry -> bb2 probability is 0x00000004 / 0x80000000 = 0.00%

Reviewed By: hans

Differential Revision: https://reviews.llvm.org/D90273
llvm/test/CodeGen/X86/switch.ll