|
517 | 517 | (GetCallerSP ...) => (LoweredGetCallerSP ...)
|
518 | 518 | (GetCallerPC ...) => (LoweredGetCallerPC ...)
|
519 | 519 |
|
520 |
| -(If cond yes no) => (NE (MOVBUreg <typ.UInt64> cond) yes no) |
| 520 | +(If cond yes no) => (NEZ (MOVBUreg <typ.UInt64> cond) yes no) |
521 | 521 | (MOVBUreg x:((SGT|SGTU) _ _)) => x
|
522 | 522 | (MOVBUreg x:(XOR (MOVVconst [1]) ((SGT|SGTU) _ _))) => x
|
523 | 523 |
|
|
902 | 902 | // Optimizations
|
903 | 903 |
|
904 | 904 | // Absorb boolean tests into block
|
905 |
| -(NE (FPFlagTrue cmp) yes no) => (FPT cmp yes no) |
906 |
| -(NE (FPFlagFalse cmp) yes no) => (FPF cmp yes no) |
907 |
| -(EQ (FPFlagTrue cmp) yes no) => (FPF cmp yes no) |
908 |
| -(EQ (FPFlagFalse cmp) yes no) => (FPT cmp yes no) |
909 |
| -(NE (XORconst [1] cmp:(SGT _ _)) yes no) => (EQ cmp yes no) |
910 |
| -(NE (XORconst [1] cmp:(SGTU _ _)) yes no) => (EQ cmp yes no) |
911 |
| -(NE (XORconst [1] cmp:(SGTconst _)) yes no) => (EQ cmp yes no) |
912 |
| -(NE (XORconst [1] cmp:(SGTUconst _)) yes no) => (EQ cmp yes no) |
913 |
| -(EQ (XORconst [1] cmp:(SGT _ _)) yes no) => (NE cmp yes no) |
914 |
| -(EQ (XORconst [1] cmp:(SGTU _ _)) yes no) => (NE cmp yes no) |
915 |
| -(EQ (XORconst [1] cmp:(SGTconst _)) yes no) => (NE cmp yes no) |
916 |
| -(EQ (XORconst [1] cmp:(SGTUconst _)) yes no) => (NE cmp yes no) |
917 |
| -(NE (SGTUconst [1] x) yes no) => (EQ x yes no) |
918 |
| -(EQ (SGTUconst [1] x) yes no) => (NE x yes no) |
919 |
| -(NE (SGTU x (MOVVconst [0])) yes no) => (NE x yes no) |
920 |
| -(EQ (SGTU x (MOVVconst [0])) yes no) => (EQ x yes no) |
921 |
| -(NE (SGTconst [0] x) yes no) => (LTZ x yes no) |
922 |
| -(EQ (SGTconst [0] x) yes no) => (GEZ x yes no) |
923 |
| -(NE (SGT x (MOVVconst [0])) yes no) => (GTZ x yes no) |
924 |
| -(EQ (SGT x (MOVVconst [0])) yes no) => (LEZ x yes no) |
925 |
| - |
926 |
| -(EQ (SGTU (MOVVconst [c]) y) yes no) && c >= -2048 && c <= 2047 => (EQ (SGTUconst [c] y) yes no) |
927 |
| -(NE (SGTU (MOVVconst [c]) y) yes no) && c >= -2048 && c <= 2047 => (NE (SGTUconst [c] y) yes no) |
928 |
| -(EQ (SUBV x y) yes no) => (BEQ x y yes no) |
929 |
| -(NE (SUBV x y) yes no) => (BNE x y yes no) |
930 |
| -(EQ (SGT x y) yes no) => (BGE y x yes no) |
931 |
| -(NE (SGT x y) yes no) => (BLT y x yes no) |
932 |
| -(EQ (SGTU x y) yes no) => (BGEU y x yes no) |
933 |
| -(NE (SGTU x y) yes no) => (BLTU y x yes no) |
| 905 | +(NEZ (FPFlagTrue cmp) yes no) => (FPT cmp yes no) |
| 906 | +(NEZ (FPFlagFalse cmp) yes no) => (FPF cmp yes no) |
| 907 | +(EQZ (FPFlagTrue cmp) yes no) => (FPF cmp yes no) |
| 908 | +(EQZ (FPFlagFalse cmp) yes no) => (FPT cmp yes no) |
| 909 | +(NEZ (XORconst [1] cmp:(SGT _ _)) yes no) => (EQZ cmp yes no) |
| 910 | +(NEZ (XORconst [1] cmp:(SGTU _ _)) yes no) => (EQZ cmp yes no) |
| 911 | +(NEZ (XORconst [1] cmp:(SGTconst _)) yes no) => (EQZ cmp yes no) |
| 912 | +(NEZ (XORconst [1] cmp:(SGTUconst _)) yes no) => (EQZ cmp yes no) |
| 913 | +(EQZ (XORconst [1] cmp:(SGT _ _)) yes no) => (NEZ cmp yes no) |
| 914 | +(EQZ (XORconst [1] cmp:(SGTU _ _)) yes no) => (NEZ cmp yes no) |
| 915 | +(EQZ (XORconst [1] cmp:(SGTconst _)) yes no) => (NEZ cmp yes no) |
| 916 | +(EQZ (XORconst [1] cmp:(SGTUconst _)) yes no) => (NEZ cmp yes no) |
| 917 | +(NEZ (SGTUconst [1] x) yes no) => (EQZ x yes no) |
| 918 | +(EQZ (SGTUconst [1] x) yes no) => (NEZ x yes no) |
| 919 | +(NEZ (SGTU x (MOVVconst [0])) yes no) => (NEZ x yes no) |
| 920 | +(EQZ (SGTU x (MOVVconst [0])) yes no) => (EQZ x yes no) |
| 921 | +(NEZ (SGTconst [0] x) yes no) => (LTZ x yes no) |
| 922 | +(EQZ (SGTconst [0] x) yes no) => (GEZ x yes no) |
| 923 | +(NEZ (SGT x (MOVVconst [0])) yes no) => (GTZ x yes no) |
| 924 | +(EQZ (SGT x (MOVVconst [0])) yes no) => (LEZ x yes no) |
| 925 | + |
| 926 | +// Convert EQZ/NEZ into more optimal branch conditions. |
| 927 | +(EQZ (SGTU (MOVVconst [c]) y) yes no) && c >= -2048 && c <= 2047 => (EQZ (SGTUconst [c] y) yes no) |
| 928 | +(NEZ (SGTU (MOVVconst [c]) y) yes no) && c >= -2048 && c <= 2047 => (NEZ (SGTUconst [c] y) yes no) |
| 929 | +(EQZ (SUBV x y) yes no) => (BEQ x y yes no) |
| 930 | +(NEZ (SUBV x y) yes no) => (BNE x y yes no) |
| 931 | +(EQZ (SGT x y) yes no) => (BGE y x yes no) |
| 932 | +(NEZ (SGT x y) yes no) => (BLT y x yes no) |
| 933 | +(EQZ (SGTU x y) yes no) => (BGEU y x yes no) |
| 934 | +(NEZ (SGTU x y) yes no) => (BLTU y x yes no) |
| 935 | +(EQZ (SGTconst [c] y) yes no) => (BGE y (MOVVconst [c]) yes no) |
| 936 | +(NEZ (SGTconst [c] y) yes no) => (BLT y (MOVVconst [c]) yes no) |
| 937 | +(EQZ (SGTUconst [c] y) yes no) => (BGEU y (MOVVconst [c]) yes no) |
| 938 | +(NEZ (SGTUconst [c] y) yes no) => (BLTU y (MOVVconst [c]) yes no) |
934 | 939 |
|
935 | 940 | // absorb constants into branches
|
936 |
| -(EQ (MOVVconst [0]) yes no) => (First yes no) |
937 |
| -(EQ (MOVVconst [c]) yes no) && c != 0 => (First no yes) |
938 |
| -(NE (MOVVconst [0]) yes no) => (First no yes) |
939 |
| -(NE (MOVVconst [c]) yes no) && c != 0 => (First yes no) |
| 941 | +(EQZ (MOVVconst [0]) yes no) => (First yes no) |
| 942 | +(EQZ (MOVVconst [c]) yes no) && c != 0 => (First no yes) |
| 943 | +(NEZ (MOVVconst [0]) yes no) => (First no yes) |
| 944 | +(NEZ (MOVVconst [c]) yes no) && c != 0 => (First yes no) |
940 | 945 | (LTZ (MOVVconst [c]) yes no) && c < 0 => (First yes no)
|
941 | 946 | (LTZ (MOVVconst [c]) yes no) && c >= 0 => (First no yes)
|
942 | 947 | (LEZ (MOVVconst [c]) yes no) && c <= 0 => (First yes no)
|
|
0 commit comments