uclamp
Unsigned Integer Clamp
UCLAMP <Zd>.<T>, <Zn>.<T>, <Zm>.<T>
Clamps unsigned integer elements between min and max (SVE2.1).
Pseudocode Operation
No pseudocode available.
Encoding
Binary Layout
01000100
31:24
size
23:22
0
21
Zm
20:16
11000
15:11
1
10
Zn
9:5
Zd
4:0
Related
More in SVE2p1
Reference
View in Arm A64 ISA Reference ↗
Arm A64 ISA
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0xC120C401 | UCLAMP { <Zd1>.<T>-<Zd2>.<T> }, <Zn>.<T>, <Zm>.<T> | A64 | 11000001 | size | 1 | Zm | 110001 | Zn | Zd | 1 | ||
| 0xC120CC01 | UCLAMP { <Zd1>.<T>-<Zd4>.<T> }, <Zn>.<T>, <Zm>.<T> | A64 | 11000001 | size | 1 | Zm | 110011 | Zn | Zd | 0 | 1 | ||
| 0x4400C400 | UCLAMP <Zd>.<T>, <Zn>.<T>, <Zm>.<T> | A64 | 01000100 | size | 0 | Zm | 11000 | 1 | Zn | Zd |
Description
Clamp each unsigned element in the destination vector to between the unsigned minimum value in the corresponding element of the first source vector and the unsigned maximum value in the corresponding element of the second source vector and destructively write the results in the corresponding elements of the destination vector. This instruction is unpredicated.
Operation
CheckSVEEnabled();
constant integer VL = CurrentVL;
constant integer elements = VL DIV esize;
bits(VL) operand1 = Z[n, VL];
bits(VL) operand2 = Z[m, VL];
bits(VL) operand3 = Z[d, VL];
bits(VL) result;
for e = 0 to elements-1
integer element1 = UInt(Elem[operand1, e, esize]);
integer element2 = UInt(Elem[operand2, e, esize]);
integer element3 = UInt(Elem[operand3, e, esize]);
integer res = Min(Max(element1, element3), element2);
Elem[result, e, esize] = res<esize-1:0>;
Z[d, VL] = result;