@@ -6067,7 +6067,6 @@ static PeepholePattern pat_movadd[] = {
60676067 { 0 , 0 , 0 , 0 , PEEP_FLAGS_DONE }
60686068};
60696069
6070-
60716070// replace mov x, #2; shl x, y; sub x, #1 with bmask x, y
60726071static PeepholePattern pat_bmask1 [] = {
60736072 { COND_ANY , OPC_MOV , PEEP_OP_SET |0 , PEEP_OP_IMM |2 , PEEP_FLAGS_P2 },
@@ -6442,6 +6441,23 @@ static int FixupDeleteInstr(int arg, IRList *irl, IR *ir) {
64426441 return 1 ;
64436442}
64446443
6444+
6445+ // convert mov x, #255; and x, y to getbyte x, y, #0
6446+ static PeepholePattern pat_mov255_and [] = {
6447+ { COND_TRUE , OPC_MOV , PEEP_OP_SET |0 , PEEP_OP_IMM |255 , PEEP_FLAGS_P2 },
6448+ { COND_TRUE , OPC_AND , PEEP_OP_MATCH |0 , PEEP_OP_SET |1 , PEEP_FLAGS_P2 },
6449+ { 0 , 0 , 0 , 0 , PEEP_FLAGS_DONE }
6450+ };
6451+
6452+ static int FixupMov255And (int arg , IRList * irl , IR * ir ) {
6453+ IR * next_ir = ir -> next ;
6454+ DeleteIR (irl , ir );
6455+ ir = next_ir ;
6456+ ReplaceOpcode (ir , OPC_GETBYTE );
6457+ ir -> src2 = NewImmediate (0 );
6458+ return 1 ;
6459+ }
6460+
64456461static int ReplaceMaxMin (int arg , IRList * irl , IR * ir )
64466462{
64476463 IR * irnext ;
@@ -7139,6 +7155,8 @@ struct Peepholes {
71397155 { pat_mux_qmux_2p , 2 , FixupQMux },
71407156
71417157 { pat_jmp_jmp , 1 , FixupDeleteInstr },
7158+
7159+ { pat_mov255_and , 1 , FixupMov255And },
71427160};
71437161
71447162
0 commit comments