Commit fea9ef3
authored
[InstCombine] Preserve profile branch weights when folding logical booleans (#161293)
Logical booleans in LLVM are represented by select statements - e.g. the
statement
```
A && B
```
is represented as
```
select i1 %A, i1 %B, i1 false
```
When LLVM folds two of the same logical booleans into a logical boolean
and a bitwise boolean (e.g. `A && B && C` -> `A && (B & C)`), the first
logical boolean is a select statement that retains the original
condition from the first logical boolean of the original statement. This
means that the new select statement has the branch weights as the
original select statement.
Tracking issue: #1473901 parent bf0a6ae commit fea9ef3
File tree
3 files changed
+33
-15
lines changed- llvm
- include/llvm/IR
- lib/Transforms/InstCombine
- test/Transforms/InstCombine
3 files changed
+33
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1722 | 1722 | | |
1723 | 1723 | | |
1724 | 1724 | | |
1725 | | - | |
| 1725 | + | |
| 1726 | + | |
1726 | 1727 | | |
1727 | 1728 | | |
1728 | | - | |
| 1729 | + | |
| 1730 | + | |
1729 | 1731 | | |
1730 | 1732 | | |
1731 | | - | |
| 1733 | + | |
| 1734 | + | |
1732 | 1735 | | |
1733 | 1736 | | |
1734 | | - | |
| 1737 | + | |
1735 | 1738 | | |
1736 | 1739 | | |
1737 | 1740 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3356 | 3356 | | |
3357 | 3357 | | |
3358 | 3358 | | |
3359 | | - | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
3360 | 3363 | | |
3361 | 3364 | | |
3362 | 3365 | | |
| |||
3398 | 3401 | | |
3399 | 3402 | | |
3400 | 3403 | | |
3401 | | - | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
3402 | 3408 | | |
3403 | 3409 | | |
3404 | 3410 | | |
| |||
Lines changed: 18 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
| 15 | + | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
161 | 161 | | |
162 | | - | |
| 162 | + | |
163 | 163 | | |
164 | 164 | | |
165 | | - | |
166 | | - | |
| 165 | + | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
506 | 506 | | |
507 | 507 | | |
508 | 508 | | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
0 commit comments