This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][Middle-end]patch for fixing PR 86519


PR 86519:New test case gcc.dg/strcmpopt_6.c fails with its introduction in r262636.

***the root cause is:

for the following call to memcmp:   __builtin_memcmp (s->s, "a", 3);
the specified length 3 is larger than the length of "a", it's clearly an out-of-bound access. This new testing case is try to claim that,
For such out-of-bound access, we should NOT expand this call at all. The new added in-lining expansion was prohibited under
such situation, However, the expansion to hardware compare insn (old code) is NOT prohibited under such situation. 
on powerPC, the above call to memcmp is expanded to hardware compare insn. therefore, the testing case failed.

***in addition to the above major issue, there is also one minor issue with the new testing case itself:

dg-final { scan-rtl-dump-times "__builtin_memcmp" 6 "expand” }
this is trying to scan the dumped .expand file to match the string “__builtin_memcmp” exactly 6 times. however, the # of times that
the string “__builtin_memcmp” appears in the .expand file varies on different target or optimization level, in order to avoid such
instability, instead of scanning the .expand file to match the string “__builtin_memcmp”,  scanning the final assembly file to match
the string “memcmp”.

please review the attached simple patch.




+2018-08-14  Qing Zhao  <>
+       PR testsuite/86519
+       * builtins.c (expand_builtin_memcmp): Do not expand the call
+       when overflow is detected.

+2018-08-14  Qing Zhao <>
+       PR testsuite/86519
+       * gcc.dg/strcmpopt_6.c: Scan the assembly file instead of
+       the .expand file.

Attachment: PR86519.patch
Description: Binary data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]