<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 - Wrong optimization around memset"
   href="https://bugs.llvm.org/show_bug.cgi?id=49208">49208</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Wrong optimization around memset
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>bogdan.gureev@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24539" name="attach_24539" title="The input llvm code">attachment 24539</a> <a href="attachment.cgi?id=24539&action=edit" title="The input llvm code">[details]</a></span>
The input llvm code

The attached example should be run with the O2 optimization level. The 'memset'
memory pointer argument is replaced by the 'undef' which causes unexpected
behavior at runtime. I don't see any reason to replace it with 'undef' since
there are writers and external function calls that are related to this memory
pointer.

Command line:
"C:\Program Files\LLVM\bin\clang.exe" -S -emit-llvm d:\work\test.bc -o
d:\work\test_out.bc -O2

I compared the input and output and the only replacement is:

from:
```
  %15 = load i8*, i8** %4, align 8, !tbaa !6
  %16 = shl nsw i64 %14, 1
  call void @llvm.memset.p0i8.i64(i8* align 2 %15, i8 0, i64 %16, i1 false) #0
```

to:
```
  %15 = shl nsw i64 %14, 1
  call void @llvm.memset.p0i8.i64(i8* align 2 undef, i8 0, i64 %15, i1 false)
#0
```</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>