Opened 19 months ago

Last modified 11 months ago

#14830 new task

Use test instead of cmp for comparison against zero.

Reported by: AndreasK Owned by:
Priority: low Milestone:
Component: Compiler (NCG) Version:
Keywords: CodeGen Cc: vanessa.mchale@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

For comparisons test r, r and cmp r, $0 are interchangeable at least on x86.

However using test leads to slightly smaller code. (Saves a byte per comparison).

A good starting point is stmtToInstrs in compiler/nativeGen/X86/CodeGen starting with how CmmCondBranch is compiled to Instructions.

From there it should be not too hard to track down the required changes.

Change History (3)

comment:1 Changed 18 months ago by AndreasK

Keywords: CodeGen added

comment:2 Changed 11 months ago by vanessamchale

stmtToInstrs calls genCondJump which as far as I can tell only uses cmp on registers, not immediate values.

comment:3 Changed 11 months ago by vanessamchale

Cc: vanessa.mchale@… added
Note: See TracTickets for help on using tickets.