| 724 | // zero/sign extend. "i" is limited to either classic unsigned (min==0) or |
| 725 | // classic signed (min=minus-power-of-2); max=power-of-2-minus-1. |
| 726 | private Node zsMask(Node val, Type t ) { |
| 727 | if( !(val._type instanceof TypeInteger tval && t instanceof TypeInteger t0 && !tval.isa(t0)) ) { |
| 728 | if( !(val._type instanceof TypeFloat tval && t instanceof TypeFloat t0 && !tval.isa(t0)) ) |
| 729 | return val; |
| 730 | // Float rounding |
| 731 | return new RoundF32Node(val).peephole(); |
| 732 | } |
| 733 | if( t0._min==0 ) // Unsigned |
| 734 | return new AndNode(val,new ConstantNode(TypeInteger.constant(t0._max)).peephole()).peephole(); |
| 735 | // Signed extension |
| 736 | int shift = Long.numberOfLeadingZeros(t0._max)-1; |
| 737 | Node shf = new ConstantNode(TypeInteger.constant(shift)).peephole(); |
| 738 | if( shf._type==TypeInteger.ZERO ) |
| 739 | return val; |
| 740 | return new SarNode(new ShlNode(val,shf.keep()).peephole(),shf.unkeep()).peephole(); |
| 741 | } |
| 742 | |
| 743 | |
| 744 | /** |