Elimination of duplicate sign extensions

Mark Shinwell shinwell@codesourcery.com
Mon Sep 24 19:59:00 GMT 2007


Fu, Chao-Ying wrote:
> Mark Shinwell wrote:
>>>   I found new regressions for fixed-point tests on 9/20/2007,
>>> due to the missing of sign/zero extension.
>>> Please check the following code for __cmpuha2 in libgcc.
>>> The OLD CODE has zero extension, but the NEW CODE doesn't.
>>> This causes wrong comparison results.
>>>
>>>   Any idea to fix this?  Is my libgcc code wrong?  Or should GCC
>>> sign/zero-extend "x" and "y" after memcpy?
>> Can you just confirm exactly which MIPS target and ABI this is
>> building for, and your exact compilation line?  I will investigate.
>>
>> Thanks,
>> Mark
>>
> 
>   The target is mipsisa32r2-elfoabi.  The ABI is old 32.
> The following is a simple test.  For integer types, GCC is correct,
> but not for fixed-point types.  Thanks a lot!

Sorry about that; an oversight on my part.  If no promotions happen
then we must make sure (as the old code did) that we don't
inadvertently mark the relevant arguments as already being
sign/zero extended.

That below fixes your testcase for me.  OK to apply pending the
running of the testsuite on a MIPS target and x86-64 bootstrap?

Mark

--


2007-09-24  Mark Shinwell  <shinwell@codesourcery.com>

	gcc/
	* combine.c (setup_incoming_promotions): Ensure that
	arguments that have not undergone mode promotions do not
	incorrectly get marked as being sign- or zero-extended.


Index: gcc/combine.c
===================================================================
--- gcc/combine.c       (revision 128656)
+++ gcc/combine.c       (working copy)
@@ -1363,15 +1363,17 @@ setup_incoming_promotions (rtx first)

        /* Eliminate sign extensions in the callee when possible.  Only
           do this when:
-        (a) the mode of the register is the same as the mode of
+        (a) a mode promotion has occurred;
+        (b) the mode of the register is the same as the mode of
              the argument as it is passed; and
-        (b) the signedness does not change across any of the 
promotions; and
-        (c) when no language-level promotions (which we cannot guarantee
+        (c) the signedness does not change across any of the 
promotions; and
+        (d) when no language-level promotions (which we cannot guarantee
              will have been done by an external caller) are necessary,
              unless we know that this function is only ever called from
              the current compilation unit -- all of whose call sites will
              do the mode1 --> mode2 promotion.  */
-      if (mode3 == mode4
+      if (mode1 != mode3
+          && mode3 == mode4
            && uns1 == uns3
           && (mode1 == mode2 || strictly_local))
          {



More information about the Gcc-patches mailing list