This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Optimize 16-bit comparison with a constant
ClosedPublic

Authored by benshi001 on Jan 21 2023, 5:45 AM.

Diff Detail

Event Timeline

benshi001 created this revision.Jan 21 2023, 5:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2023, 5:45 AM
benshi001 requested review of this revision.Jan 21 2023, 5:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 21 2023, 5:45 AM
benshi001 added inline comments.Jan 21 2023, 6:14 AM
llvm/lib/Target/AVR/AVRISelLowering.cpp
660

Only a zero constant with be put at left by previous DAG transform, all other non-zero constant are dropped as RHS. So we have to handle it specially.

llvm/test/CodeGen/AVR/cmp.ll
213

x > 0 is compiled to 0 < x, and the low 0 value byte and the high 0 value byte are represented by the zero register.

benshi001 updated this revision to Diff 491070.Jan 21 2023, 6:16 AM
benshi001 added inline comments.Jan 21 2023, 6:20 AM
llvm/test/CodeGen/AVR/cmp.ll
232

x > 126 is compiled to x >= 127, the low byte value is 127, and the high byte valued zero is represented via the zero register.

252

x > 1023 is compiled to x >= 1024, the high byte is 4, and the low byte is represented via the zero register.

benshi001 updated this revision to Diff 491071.Jan 21 2023, 6:23 AM
benshi001 updated this revision to Diff 491116.Jan 21 2023, 6:46 PM
benshi001 updated this revision to Diff 494966.Feb 5 2023, 5:38 PM
benshi001 updated this revision to Diff 494967.Feb 5 2023, 5:53 PM
benshi001 added inline comments.Feb 5 2023, 6:01 PM
llvm/test/CodeGen/AVR/cmp.ll
243

x > 126 is compiled to x >= 127, the low byte value is 127, and the high byte valued zero is represented via the zero register.

289

x > 1023 is compiled to x >= 1024, the high byte is 4, and the low byte is represented via the zero register.

This revision is now accepted and ready to land.Feb 8 2023, 11:09 PM
This revision was automatically updated to reflect the committed changes.