These asserts are based on the assumption that the order of true/false operands in a select and those in the compare would always be the same.
This fixes PR39595.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Consider this case:
%9 = icmp ugt i32 %5, %8 %10 = select i1 %9, i32 %8, i32 %5, !prof !2
Here the order of true/false operands of the select and the compare are different. This breaks the checks (X == SI.getTrueValue() && Y == SI.getFalseValue()) and (X == SI.getFalseValue() && Y == SI.getTrueValue())
Those asserts are validating the metadata correctness. Deleting them is hiding a bug I think.
test/Transforms/InstCombine/select-pr39595.ll | ||
---|---|---|
10 ↗ | (On Diff #173452) | I dont' think most of the attributes on this function are necessary to show the bug. |
19 ↗ | (On Diff #173452) | Can we hit this bug without these loads? |
31 ↗ | (On Diff #173452) | This function_entry_count looks unnecessary to demonstrate the issue. |
@craig.topper Could you please review this? This is a blocker for our internal release.
Transforms/InstCombine/select-pr39595.ll | ||
---|---|---|
9 ↗ | (On Diff #173567) | I think the branch metadata is incorrect here. It should have been swapped. The original operands were "not %y for true" and "not %x" for false with the false case occuring more often meaning not %x is the most often case. Now the operands are %x for true and %y for false, but the branch metadata is the same so now it says %y occurs more often. |
Transforms/InstCombine/InstCombineSelect.cpp | ||
---|---|---|
1823 ↗ | (On Diff #173567) | I think "Swapped" in the if should be replace with the condition from the assert "X == SI.getFalseValue() && Y == SI.getTrueValue()". Which is what I had in the original patch that went up for review, but was asked to just use Swapped. Which was wrong I guess. |