File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -2508,9 +2508,17 @@ CompileBasicBoolExpression(IRList *irl, AST *expr)
2508
2508
/* note that lhs cannot be a constant */
2509
2509
if (lhs && lhs -> kind == IMM_INT ) {
2510
2510
Operand * tmp = lhs ;
2511
- lhs = rhs ;
2512
- rhs = tmp ;
2513
- cond = FlipSides (cond );
2511
+ if (rhs && rhs -> kind == IMM_INT ) {
2512
+ // we have to put lhs into a temp register
2513
+ tmp = NewFunctionTempRegister ();
2514
+ EmitMove (irl , tmp , lhs , expr );
2515
+ lhs = tmp ;
2516
+ } else {
2517
+ // flip left and right to save a move
2518
+ lhs = rhs ;
2519
+ rhs = tmp ;
2520
+ cond = FlipSides (cond );
2521
+ }
2514
2522
}
2515
2523
// If comparing with constant, try for a condition that only uses C
2516
2524
// but only if it's correct and it won't horribly pessimize everything
You can’t perform that action at this time.
0 commit comments