|
844 | 844 | => x |
845 | 845 |
|
846 | 846 | // Load from a region just copied by Move can read directly from the source. |
847 | | -(Load <t1> op:(OffPtr [o1] p1) move:(Move [n] p2 src mem)) |
| 847 | +(Load <t1> op1:(OffPtr [o1] p1) move:(Move [n] p2 src mem)) |
848 | 848 | && o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p2) |
849 | 849 | && !isVolatile(src) |
850 | | - => @move.Block (Load <t1> (OffPtr <op.Type> [o1] src) mem) |
| 850 | + => @move.Block (Load <t1> (OffPtr <op1.Type> [o1] src) mem) |
851 | 851 |
|
852 | 852 | // Pass constants through math.Float{32,64}bits and math.Float{32,64}frombits |
853 | 853 | (Load <t1> p1 (Store {t2} p2 (Const64 [x]) _)) && isSamePtr(p1,p2) && t2.Size() == 8 && is64BitFloat(t1) && !math.IsNaN(math.Float64frombits(uint64(x))) => (Const64F [math.Float64frombits(uint64(x))]) |
|
856 | 856 | (Load <t1> p1 (Store {t2} p2 (Const32F [x]) _)) && isSamePtr(p1,p2) && t2.Size() == 4 && is32BitInt(t1) => (Const32 [int32(math.Float32bits(x))]) |
857 | 857 |
|
858 | 858 | // Float Loads up to Zeros so they can be constant folded. |
859 | | -(Load <t1> op:(OffPtr [o1] p1) |
| 859 | +(Load <t1> op1:(OffPtr [o1] p1) |
860 | 860 | (Store {t2} p2 _ |
861 | 861 | mem:(Zero [n] p3 _))) |
862 | 862 | && o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p3) |
863 | 863 | && CanSSA(t1) |
864 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
865 | | - => @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p3) mem) |
866 | | -(Load <t1> op:(OffPtr [o1] p1) |
| 864 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
| 865 | + => @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p3) mem) |
| 866 | +(Load <t1> op1:(OffPtr [o1] p1) |
867 | 867 | (Store {t2} p2 _ |
868 | 868 | (Store {t3} p3 _ |
869 | 869 | mem:(Zero [n] p4 _)))) |
870 | 870 | && o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p4) |
871 | 871 | && CanSSA(t1) |
872 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
873 | | - && disjoint(op, t1.Size(), p3, t3.Size()) |
874 | | - => @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p4) mem) |
875 | | -(Load <t1> op:(OffPtr [o1] p1) |
| 872 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
| 873 | + && disjoint(op1, t1.Size(), p3, t3.Size()) |
| 874 | + => @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p4) mem) |
| 875 | +(Load <t1> op1:(OffPtr [o1] p1) |
876 | 876 | (Store {t2} p2 _ |
877 | 877 | (Store {t3} p3 _ |
878 | 878 | (Store {t4} p4 _ |
879 | 879 | mem:(Zero [n] p5 _))))) |
880 | 880 | && o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p5) |
881 | 881 | && CanSSA(t1) |
882 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
883 | | - && disjoint(op, t1.Size(), p3, t3.Size()) |
884 | | - && disjoint(op, t1.Size(), p4, t4.Size()) |
885 | | - => @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p5) mem) |
886 | | -(Load <t1> op:(OffPtr [o1] p1) |
| 882 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
| 883 | + && disjoint(op1, t1.Size(), p3, t3.Size()) |
| 884 | + && disjoint(op1, t1.Size(), p4, t4.Size()) |
| 885 | + => @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p5) mem) |
| 886 | +(Load <t1> op1:(OffPtr [o1] p1) |
887 | 887 | (Store {t2} p2 _ |
888 | 888 | (Store {t3} p3 _ |
889 | 889 | (Store {t4} p4 _ |
890 | 890 | (Store {t5} p5 _ |
891 | 891 | mem:(Zero [n] p6 _)))))) |
892 | 892 | && o1 >= 0 && o1+t1.Size() <= n && isSamePtr(p1, p6) |
893 | 893 | && CanSSA(t1) |
894 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
895 | | - && disjoint(op, t1.Size(), p3, t3.Size()) |
896 | | - && disjoint(op, t1.Size(), p4, t4.Size()) |
897 | | - && disjoint(op, t1.Size(), p5, t5.Size()) |
898 | | - => @mem.Block (Load <t1> (OffPtr <op.Type> [o1] p6) mem) |
| 894 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
| 895 | + && disjoint(op1, t1.Size(), p3, t3.Size()) |
| 896 | + && disjoint(op1, t1.Size(), p4, t4.Size()) |
| 897 | + && disjoint(op1, t1.Size(), p5, t5.Size()) |
| 898 | + => @mem.Block (Load <t1> (OffPtr <op1.Type> [o1] p6) mem) |
899 | 899 |
|
900 | 900 | // Zero to Load forwarding. |
901 | 901 | (Load <t1> (OffPtr [o] p1) (Zero [n] p2 _)) |
|
964 | 964 | && isConstZero(x) |
965 | 965 | && o >= 0 && t.Size() + o <= n && isSamePtr(p1, p2) |
966 | 966 | => mem |
967 | | -(Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Zero [n] p3 _))) |
| 967 | +(Store {t1} op1:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Zero [n] p3 _))) |
968 | 968 | && isConstZero(x) |
969 | 969 | && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p3) |
970 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
| 970 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
971 | 971 | => mem |
972 | | -(Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Zero [n] p4 _)))) |
| 972 | +(Store {t1} op1:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Zero [n] p4 _)))) |
973 | 973 | && isConstZero(x) |
974 | 974 | && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p4) |
975 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
976 | | - && disjoint(op, t1.Size(), p3, t3.Size()) |
| 975 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
| 976 | + && disjoint(op1, t1.Size(), p3, t3.Size()) |
977 | 977 | => mem |
978 | | -(Store {t1} op:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Zero [n] p5 _))))) |
| 978 | +(Store {t1} op1:(OffPtr [o1] p1) x mem:(Store {t2} p2 _ (Store {t3} p3 _ (Store {t4} p4 _ (Zero [n] p5 _))))) |
979 | 979 | && isConstZero(x) |
980 | 980 | && o1 >= 0 && t1.Size() + o1 <= n && isSamePtr(p1, p5) |
981 | | - && disjoint(op, t1.Size(), p2, t2.Size()) |
982 | | - && disjoint(op, t1.Size(), p3, t3.Size()) |
983 | | - && disjoint(op, t1.Size(), p4, t4.Size()) |
| 981 | + && disjoint(op1, t1.Size(), p2, t2.Size()) |
| 982 | + && disjoint(op1, t1.Size(), p3, t3.Size()) |
| 983 | + && disjoint(op1, t1.Size(), p4, t4.Size()) |
984 | 984 | => mem |
985 | 985 |
|
986 | 986 | // Collapse OffPtr |
|
1771 | 1771 | && n >= o2 + t2.Size() |
1772 | 1772 | && clobber(store) |
1773 | 1773 | => (Zero {t1} [n] p1 mem) |
1774 | | -(Move {t1} [n] dst1 src1 store:(Store {t2} op:(OffPtr [o2] dst2) _ mem)) |
| 1774 | +(Move {t1} [n] dst1 src1 store:(Store {t2} op1:(OffPtr [o2] dst2) _ mem)) |
1775 | 1775 | && isSamePtr(dst1, dst2) && store.Uses == 1 |
1776 | 1776 | && n >= o2 + t2.Size() |
1777 | | - && disjoint(src1, n, op, t2.Size()) |
| 1777 | + && disjoint(src1, n, op1, t2.Size()) |
1778 | 1778 | && clobber(store) |
1779 | 1779 | => (Move {t1} [n] dst1 src1 mem) |
1780 | 1780 |
|
|
2344 | 2344 |
|
2345 | 2345 | // Transform some CondSelect into math operations. |
2346 | 2346 | // if b { x += c } => x += b * c |
2347 | | -(CondSelect op:(Add8 <t> x c:(Const8)) x bool) && |
2348 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2347 | +(CondSelect op1:(Add8 <t> x c:(Const8)) x bool) && |
| 2348 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2349 | 2349 | (Add8 x (Mul8 <t> c (CvtBoolToUint8 <t> bool))) |
2350 | | -(CondSelect op:(Add(64|32|16) <t> x c:(Const(64|32|16))) x bool) && |
2351 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2350 | +(CondSelect op1:(Add(64|32|16) <t> x c:(Const(64|32|16))) x bool) && |
| 2351 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2352 | 2352 | (Add(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool)))) |
2353 | 2353 | // if !b { x += c } => x += !b * c |
2354 | | -(CondSelect x op:(Add8 <t> x c:(Const8)) bool) && |
2355 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2354 | +(CondSelect x op1:(Add8 <t> x c:(Const8)) bool) && |
| 2355 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2356 | 2356 | (Add8 x (Mul8 <t> c (CvtBoolToUint8 <t> (Not <bool.Type> bool)))) |
2357 | | -(CondSelect x op:(Add(64|32|16) <t> x c:(Const(64|32|16))) bool) && |
2358 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2357 | +(CondSelect x op1:(Add(64|32|16) <t> x c:(Const(64|32|16))) bool) && |
| 2358 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2359 | 2359 | (Add(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool))))) |
2360 | 2360 |
|
2361 | 2361 | // if b { x += c } => x -= b * -c // looks redundant but useful if the arch can inline materialize -c but not c |
2362 | | -(CondSelect op:(Add8 <t> x c:(Const8 [consT])) x bool) && |
2363 | | - !rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) && |
2364 | | - rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) => |
| 2362 | +(CondSelect op1:(Add8 <t> x c:(Const8 [consT])) x bool) && |
| 2363 | + !rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) && |
| 2364 | + rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) => |
2365 | 2365 | (Sub8 x (Mul8 <t> (Const8 <t> [-consT]) (CvtBoolToUint8 <t> bool))) |
2366 | | -(CondSelect op:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) x bool) && |
2367 | | - !rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) && |
2368 | | - rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) => |
| 2366 | +(CondSelect op1:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) x bool) && |
| 2367 | + !rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) && |
| 2368 | + rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) => |
2369 | 2369 | (Sub(64|32|16) x (Mul(64|32|16) <t> (Const(64|32|16) <t> [-consT]) (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool)))) |
2370 | 2370 | // if !b { x += c } => x -= !b * -c // looks redundant but useful if the arch can inline materialize -c but not c |
2371 | | -(CondSelect x op:(Add8 <t> x c:(Const8 [consT])) bool) && |
2372 | | - !rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) && |
2373 | | - rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) => |
| 2371 | +(CondSelect x op1:(Add8 <t> x c:(Const8 [consT])) bool) && |
| 2372 | + !rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) && |
| 2373 | + rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) => |
2374 | 2374 | (Sub8 x (Mul8 <t> (Const8 <t> [-consT]) (CvtBoolToUint8 <t> (Not <bool.Type> bool)))) |
2375 | | -(CondSelect x op:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) bool) && |
2376 | | - !rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) && |
2377 | | - rewriteCondSelectIntoMath(config, addToSub(op.Op), -c.AuxInt) => |
| 2375 | +(CondSelect x op1:(Add(64|32|16) <t> x c:(Const(64|32|16) [consT])) bool) && |
| 2376 | + !rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) && |
| 2377 | + rewriteCondSelectIntoMath(config, addToSub(op1.Op), -c.AuxInt) => |
2378 | 2378 | (Sub(64|32|16) x (Mul(64|32|16) <t> (Const(64|32|16) <t> [-consT]) (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool))))) |
2379 | 2379 |
|
2380 | 2380 | // if b { x <<= 1 } => x <<= b |
|
2390 | 2390 | (CondSelect x (Rsh(64|32|16|8)Ux64 x (Const64 [1])) bool) => (Rsh(64|32|16|8)Ux8 [true] x (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool))) |
2391 | 2391 |
|
2392 | 2392 | // if b { x |= c } => x |= b * c |
2393 | | -(CondSelect op:(Or8 <t> x c:(Const8)) x bool) && |
2394 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2393 | +(CondSelect op1:(Or8 <t> x c:(Const8)) x bool) && |
| 2394 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2395 | 2395 | (Or8 x (Mul8 <t> c (CvtBoolToUint8 <t> bool))) |
2396 | | -(CondSelect op:(Or(64|32|16) <t> x c:(Const(64|32|16))) x bool) && |
2397 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2396 | +(CondSelect op1:(Or(64|32|16) <t> x c:(Const(64|32|16))) x bool) && |
| 2397 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2398 | 2398 | (Or(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool)))) |
2399 | 2399 | // if !b { x |= c } => x |= !b * c |
2400 | | -(CondSelect x op:(Or8 <t> x c:(Const8)) bool) && |
2401 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2400 | +(CondSelect x op1:(Or8 <t> x c:(Const8)) bool) && |
| 2401 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2402 | 2402 | (Or8 x (Mul8 <t> c (CvtBoolToUint8 <t> (Not <bool.Type> bool)))) |
2403 | | -(CondSelect x op:(Or(64|32|16) <t> x c:(Const(64|32|16))) bool) && |
2404 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2403 | +(CondSelect x op1:(Or(64|32|16) <t> x c:(Const(64|32|16))) bool) && |
| 2404 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2405 | 2405 | (Or(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool))))) |
2406 | 2406 |
|
2407 | 2407 | // if b { x ^= c } => x ^= b * c |
2408 | | -(CondSelect op:(Xor8 <t> x c:(Const8)) x bool) && |
2409 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2408 | +(CondSelect op1:(Xor8 <t> x c:(Const8)) x bool) && |
| 2409 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2410 | 2410 | (Xor8 x (Mul8 <t> c (CvtBoolToUint8 <t> bool))) |
2411 | | -(CondSelect op:(Xor(64|32|16) <t> x c:(Const(64|32|16))) x bool) && |
2412 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2411 | +(CondSelect op1:(Xor(64|32|16) <t> x c:(Const(64|32|16))) x bool) && |
| 2412 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2413 | 2413 | (Xor(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> bool)))) |
2414 | 2414 | // if !b { x ^= c } => x ^= !b * c |
2415 | | -(CondSelect x op:(Xor8 <t> x c:(Const8)) bool) && |
2416 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2415 | +(CondSelect x op1:(Xor8 <t> x c:(Const8)) bool) && |
| 2416 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2417 | 2417 | (Xor8 x (Mul8 <t> c (CvtBoolToUint8 <t> (Not <bool.Type> bool)))) |
2418 | | -(CondSelect x op:(Xor(64|32|16) <t> x c:(Const(64|32|16))) bool) && |
2419 | | - rewriteCondSelectIntoMath(config, op.Op, c.AuxInt) => |
| 2418 | +(CondSelect x op1:(Xor(64|32|16) <t> x c:(Const(64|32|16))) bool) && |
| 2419 | + rewriteCondSelectIntoMath(config, op1.Op, c.AuxInt) => |
2420 | 2420 | (Xor(64|32|16) x (Mul(64|32|16) <t> c (ZeroExt8to(64|32|16) <t> (CvtBoolToUint8 <types.Types[types.TUINT8]> (Not <bool.Type> bool))))) |
2421 | 2421 |
|
2422 | 2422 | // bool(int(x)) => x |
|
0 commit comments