File tree 3 files changed +462
-0
lines changed
src/cmd/compile/internal/ssa
3 files changed +462
-0
lines changed Original file line number Diff line number Diff line change 628
628
// x & 1 == 0 -> (x & 1) ^ 1
629
629
(SETAE (BT(L|Q)const [0] x)) => (XORLconst [1] (ANDLconst <typ.Bool> [1] x))
630
630
631
+ // Shorten compare by rewriting x < 128 as x <= 127, which can be encoded in a single-byte immediate on x86.
632
+ (SETL c:(CMP(Q|L)const [128] x)) && c.Uses == 1 => (SETLE (CMP(Q|L)const [127] x))
633
+ (SETB c:(CMP(Q|L)const [128] x)) && c.Uses == 1 => (SETBE (CMP(Q|L)const [127] x))
634
+
635
+ // x >= 128 -> x > 127
636
+ (SETGE c:(CMP(Q|L)const [128] x)) && c.Uses == 1 => (SETG (CMP(Q|L)const [127] x))
637
+ (SETAE c:(CMP(Q|L)const [128] x)) && c.Uses == 1 => (SETA (CMP(Q|L)const [127] x))
638
+
639
+ (CMOVQLT x y c:(CMP(Q|L)const [128] z)) && c.Uses == 1 => (CMOVQLE x y (CMP(Q|L)const [127] z))
640
+ (CMOVLLT x y c:(CMP(Q|L)const [128] z)) && c.Uses == 1 => (CMOVLLE x y (CMP(Q|L)const [127] z))
641
+ (LT c:(CMP(Q|L)const [128] z) yes no) && c.Uses == 1 => (LE (CMP(Q|L)const [127] z) yes no)
642
+ (CMOVQGE x y c:(CMP(Q|L)const [128] z)) && c.Uses == 1 => (CMOVQGT x y (CMP(Q|L)const [127] z))
643
+ (CMOVLGE x y c:(CMP(Q|L)const [128] z)) && c.Uses == 1 => (CMOVLGT x y (CMP(Q|L)const [127] z))
644
+ (GE c:(CMP(Q|L)const [128] z) yes no) && c.Uses == 1 => (GT (CMP(Q|L)const [127] z) yes no)
645
+
631
646
// Recognize bit tests: a&(1<<b) != 0 for b suitably bounded
632
647
// Note that BTx instructions use the carry bit, so we need to convert tests for zero flag
633
648
// into tests for carry flags.
You can’t perform that action at this time.
0 commit comments