Commit d532641
authored
[libclc] Improve __clc_min/max/clamp implementation (#172599)
Replace __clc_max/min with __clc_fmax/fmin in __clc_clamp. FP
__clc_min/max/clamp now lowers to @llvm.minimumnum/@llvm.maximumnum, and
integer clamp lowers to @llvm.umin/@llvm.umax. This reduce fcmp+select
chains and improving codegen. Example change to amdgcn--amdhsa.bc:
```
in function _Z5clamphhh:
> %4 = icmp ugt i8 %0, %2
%4 = tail call noundef i8 @llvm.umax.i8(i8 %0, i8 %1)
> %6 = select i1 %4, i8 %2, i8 %5
> ret i8 %6
< %5 = tail call noundef i8 @llvm.umin.i8(i8 %2, i8 %4)
< ret i8 %5
in function _Z5clampddd:
in block %3 / %3:
> %4 = fcmp ogt double %0, %2
> %5 = fcmp olt double %0, %1
> %6 = select i1 %5, double %1, double %0
> %7 = select i1 %4, double %2, double %6
> ret double %7
< %4 = tail call noundef double @llvm.maximumnum.f64(double %0, double %1)
< %5 = tail call noundef double @llvm.minimumnum.f64(double %4, double %2)
< ret double %5
```1 parent 37a73d5 commit d532641
File tree
6 files changed
+43
-5
lines changed6 files changed
+43
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | | - | |
| 19 | + | |
21 | 20 | | |
22 | 21 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
9 | 25 | | |
10 | 26 | | |
11 | 27 | | |
| |||
16 | 32 | | |
17 | 33 | | |
18 | 34 | | |
19 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
9 | 24 | | |
10 | 25 | | |
11 | 26 | | |
| |||
16 | 31 | | |
17 | 32 | | |
18 | 33 | | |
19 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments