This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Optimize 16-bit comparison with constant
ClosedPublic

Authored by benshi001 on Jan 2 2021, 7:46 AM.

Diff Detail

Event Timeline

benshi001 created this revision.Jan 2 2021, 7:46 AM
benshi001 requested review of this revision.Jan 2 2021, 7:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 2 2021, 7:46 AM
benshi001 updated this revision to Diff 314245.Jan 2 2021, 8:28 AM

for the C code like

int a;
if (a == 2333)

The generated AVR assembly is optimized from

ldi     r18, 29
ldi     r19, 9
cp      r24, r18
cpc     r25, r19

to

ldi     r18, 9
cpi     r24, 29
cpc     r25, r18
dylanmckay accepted this revision.Jan 23 2021, 1:52 AM
This revision is now accepted and ready to land.Jan 23 2021, 1:52 AM
This revision was automatically updated to reflect the committed changes.