GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 12083 - have builtin function comparing memory backwards
Summary: have builtin function comparing memory backwards
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 3.3
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-27 20:44 UTC by Yuri
Modified: 2012-02-22 13:04 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-24 19:53:18


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yuri 2003-08-27 20:44:25 UTC
Right now if code has function "memcmp" compiler will inline/optimize it into
"cld; repz cmpsb" - type of code inassembly on i386.

But if the problem is to compare backwards, assembly still can do it efficiently
just replacing cld with std and moving pointers to the end of block.

But from C this efficiency is unavailable.

I propose to add GCC-extention: add builtin function "gcc_rmemcmp" which
will compare memory in reverse direction.

Yuri (yuri at tsoft dot com).

PS: I will try to work on such patch myself once I have time.
Comment 1 Zack Weinberg 2003-08-27 21:11:44 UTC
The appropriate name for such an intrinsic would be __builtin_rmemcmp.

I admit to not seeing the utility, but additional intrinsics don't cost much,
and you must have a use for such a thing.
Comment 2 xiaoyuanbo 2012-02-22 13:04:37 UTC
in memcmp i sure