<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - DSE fails to shorten sizes of memsets"
   href="https://bugs.llvm.org/show_bug.cgi?id=50120">50120</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>DSE fails to shorten sizes of memsets
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>david.bolvansky@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre><a href="https://godbolt.org/z/48TT9dPvP">https://godbolt.org/z/48TT9dPvP</a>

#include <string.h>

struct pam {
  void *p1;
  void *p2;
  #ifdef LONG
  unsigned long size;
  #else
  unsigned int size;
  unsigned int pad;
  #endif
};

extern int use(struct pam *param);

unsigned int foo(void) {
  struct pam s_pam;
  memset(&s_pam, 0, sizeof(struct pam));
  s_pam.size = 1;
  return use(&s_pam);
}



For LONG case DSE changes 24->16
  call void @llvm.memset.p0i8.i64(i8* noundef nonnull align 8
dereferenceable(24) %2, i8 0, i64 16, i1 false), !dbg !24
For INT case - no change - 24->24 
  call void @llvm.memset.p0i8.i64(i8* noundef nonnull align 8
dereferenceable(24) %2, i8 0, i64 24, i1 false), !dbg !23


INT case:
foo(): # @foo()
  sub rsp, 24
  xorps xmm0, xmm0
  movaps xmmword ptr [rsp], xmm0
  mov qword ptr [rsp + 16], 0        // ******
  mov dword ptr [rsp + 16], 1        // ******
  mov rdi, rsp
  call use(pam*)
  add rsp, 24
  ret

LONG case:
foo(): # @foo()
  sub rsp, 24
  xorps xmm0, xmm0
  movaps xmmword ptr [rsp], xmm0
  mov qword ptr [rsp + 16], 1        // ******
  mov rdi, rsp
  call use(pam*)
  add rsp, 24
  ret</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>