Hi All,

Could a gatekeeper review this patch?

The test case is as following, and the bug is triggered, when compiling it
with -O2.

#include <string.h>

struct x{
  int y;
  int z;
};

int foo()
{
  struct x xyz,abc;
  int i;
  memset(&xyz,0,sizeof(xyz));
  i = 1;
  while( i < 0 )
  {
    abc.y += xyz.z;
    xyz.z += 1;
    i+=i;
  }
  memcpy(&abc,&xyz,sizeof(xyz));
  return abc.y ;
}

The issue is that after WOPT remove the while loop, it renames SSA and
connect the MSTORE and MLOAD lowered from memset and memcpy respectively.
It would then try to copy propagate

  LDC 0
  LDA ...
  LDC 8
MSTORE

to

  LDA ...
  LDC 8
MLOAD

And, it fails to make a CVT op of type I4 and M.

As WOPT is not doing copy propagation for MLOAD, so we just abandon the
opportunity as a fix.
It should be noted that, the DEF is passing the "Propagatable" test, as it
is LDC I4, while usual DEF of an MLOAD would be MLOAD.

The patch is as following:
Index: opt_prop.cxx
===================================================================
--- opt_prop.cxx (revision 3827)
+++ opt_prop.cxx (working copy)
@@ -1307,6 +1307,16 @@
   if (prop == NOT_PROPAGATABLE)
     return NULL;

+  // MLOAD may be defined by a MSTORE as following
+  //   LDC 0
+  //   LDA
+  //   LDC
+  //  MSTORE
+  // The definition would pass Propagatable test, but we are not going
+  // to propagate it.
+  if (x->Opr() == OPR_MLOAD)
+    return NULL;
+
   x->DecUsecnt();
   if (icopy_phase)
     Htable()->Inc_inputprops();

Best Regards,
Yiran
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Open64-devel mailing list
Open64-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/open64-devel

Reply via email to