| 926 | // zero/sign extend. "i" is limited to either classic unsigned (min==0) or |
| 927 | // classic signed (min=minus-power-of-2); max=power-of-2-minus-1. |
| 928 | private Node zsMask(Node val, Type t ) { |
| 929 | if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) { |
| 930 | if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) ) |
| 931 | return val; |
| 932 | // Float rounding |
| 933 | return new RoundF32Node(val).peephole(); |
| 934 | } |
| 935 | if( t0._min==0 ) // Unsigned |
| 936 | return new AndNode(val,con(t0._max)).peephole(); |
| 937 | // Signed extension |
| 938 | int shift = Long.numberOfLeadingZeros(t0._max)-1; |
| 939 | Node shf = con(shift); |
| 940 | if( shf._type==TypeInteger.ZERO ) |
| 941 | return val; |
| 942 | return new SarNode(new ShlNode(val,shf.keep()).peephole(),shf.unkeep()).peephole(); |
| 943 | } |
| 944 | |
| 945 | |
| 946 | /** |