@@ -516,6 +516,20 @@ func (ft *factsTable) update(parent *Block, v, w *Value, d domain, r relation) {
516
516
vmin = parent .NewValue0I (parent .Pos , OpConst32 , parent .Func .Config .Types .Int32 , min )
517
517
vmax = parent .NewValue0I (parent .Pos , OpConst32 , parent .Func .Config .Types .Int32 , max )
518
518
519
+ case 2 :
520
+ min = int64 (int16 (w .AuxInt ) - int16 (delta ))
521
+ max = int64 (int16 (^ uint16 (0 )>> 1 ) - int16 (delta ))
522
+
523
+ vmin = parent .NewValue0I (parent .Pos , OpConst16 , parent .Func .Config .Types .Int16 , min )
524
+ vmax = parent .NewValue0I (parent .Pos , OpConst16 , parent .Func .Config .Types .Int16 , max )
525
+
526
+ case 1 :
527
+ min = int64 (int8 (w .AuxInt ) - int8 (delta ))
528
+ max = int64 (int8 (^ uint8 (0 )>> 1 ) - int8 (delta ))
529
+
530
+ vmin = parent .NewValue0I (parent .Pos , OpConst8 , parent .Func .Config .Types .Int8 , min )
531
+ vmax = parent .NewValue0I (parent .Pos , OpConst8 , parent .Func .Config .Types .Int8 , max )
532
+
519
533
default :
520
534
panic ("unimplemented" )
521
535
}
@@ -1520,16 +1534,20 @@ func isConstDelta(v *Value) (w *Value, delta int64) {
1520
1534
switch v .Op {
1521
1535
case OpAdd32 , OpSub32 :
1522
1536
cop = OpConst32
1537
+ case OpAdd16 , OpSub16 :
1538
+ cop = OpConst16
1539
+ case OpAdd8 , OpSub8 :
1540
+ cop = OpConst8
1523
1541
}
1524
1542
switch v .Op {
1525
- case OpAdd64 , OpAdd32 :
1543
+ case OpAdd64 , OpAdd32 , OpAdd16 , OpAdd8 :
1526
1544
if v .Args [0 ].Op == cop {
1527
1545
return v .Args [1 ], v .Args [0 ].AuxInt
1528
1546
}
1529
1547
if v .Args [1 ].Op == cop {
1530
1548
return v .Args [0 ], v .Args [1 ].AuxInt
1531
1549
}
1532
- case OpSub64 , OpSub32 :
1550
+ case OpSub64 , OpSub32 , OpSub16 , OpSub8 :
1533
1551
if v .Args [1 ].Op == cop {
1534
1552
aux := v .Args [1 ].AuxInt
1535
1553
if aux != - aux { // Overflow; too bad
0 commit comments