Summary: | memcmp(i,j,4) should use word (SI) subtraction | ||
---|---|---|---|
Product: | gcc | Reporter: | Andrew Pinski <pinskia> |
Component: | middle-end | Assignee: | Not yet assigned to anyone <unassigned> |
Status: | NEW --- | ||
Severity: | enhancement | CC: | dimhen, gabravier, gcc-bugzilla, msebor, ville.voutilainen |
Priority: | P2 | Keywords: | missed-optimization |
Version: | 3.4.0 | ||
Target Milestone: | --- | ||
See Also: | https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78257 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2007-07-01 01:22:19 | |
Bug Depends on: | 52171 | ||
Bug Blocks: |
Description
Andrew Pinski
2003-08-28 03:00:40 UTC
*** Bug 12087 has been marked as a duplicate of this bug. *** I have got my own bug. Add the attribute may_alias to the (const unsigned int *) when creating the type will make sure there is no aliasing problems. The 2 (short case) instead of 4 should be able to be done the same way and also the 8 case (long long). I have to check on the size of the types but that is the only thing different than the 1 size case that is already there besides the extra attribute, I should be able to do this tonight. Posted patch <http://gcc.gnu.org/ml/gcc-patches/2003-08/msg01826.html>. Cannot be done as there are cases where it would return the wrong result. Why do you think it would give wrong results? On big endian, it should work IMHO, on little endian, you might also be able to do something on some platforms (see http://gcc.gnu.org/ml/gcc-patches/2003-04/msg01723.html) Reopening based on new thoughts but this will not go in for 3.4 at least by me because I am too busy. *** Bug 3508 has been marked as a duplicate of this bug. *** I don't have time to work on this any more. I am going to fix up my patch for 4.3.0. I am no longer working on this. This bug means that for struct X { char a[8]; }; bool f(X x, X y) { return __builtin_memcmp(x.a, y.a, 8); } gcc emits: subq $40, %rsp .cfi_def_cfa_offset 48 movl $8, %edx movq %rdi, 16(%rsp) leaq 16(%rsp), %rdi movq %rsi, (%rsp) movq %rsp, %rsi call memcmp testl %eax, %eax setne %al addq $40, %rsp .cfi_def_cfa_offset 8 ret while clang emits: movq %rdi, -8(%rsp) movq %rsi, -16(%rsp) cmpq %rsi, -8(%rsp) setne %al retq (which is still suboptimal due to llvm bug #20673). Thank you for the additional information you have supplied regarding this Bug report. This is an automatically generated reply to let you know your message has been received. Your message has not been forwarded to the package maintainers or other interested parties; you should ensure that the developers are aware of the problem you have entered into the system - preferably quoting the Bug reference number, #85535. If you wish to submit further information on this problem, please send it to 85535-quiet@bugs.debian.org. Please do not send mail to owner@bugs.debian.org unless you wish to report a problem with the Bug-tracking system. It's also worth noting that this affects operator== for std::array. :( Thank you for the additional information you have supplied regarding this Bug report. This is an automatically generated reply to let you know your message has been received. Your message has not been forwarded to the package maintainers or other interested parties; you should ensure that the developers are aware of the problem you have entered into the system - preferably quoting the Bug reference number, #85535. If you wish to submit further information on this problem, please send it to 85535-quiet@bugs.debian.org. Please do not send mail to owner@bugs.debian.org unless you wish to report a problem with the Bug-tracking system. Thank you for the additional information you have supplied regarding this Bug report. This is an automatically generated reply to let you know your message has been received. Your message has not been forwarded to the package maintainers or other interested parties; you should ensure that the developers are aware of the problem you have entered into the system - preferably quoting the Bug reference number, #85535. If you wish to submit further information on this problem, please send it to 85535-quiet@bugs.debian.org. Please do not send mail to owner@bugs.debian.org unless you wish to report a problem with the Bug-tracking system. See also bug 78257 for a related enhancement. *** Bug 96603 has been marked as a duplicate of this bug. *** |