<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - operation on bit-fields shall yield results reduced to bit-field size"
   href="https://llvm.org/bugs/show_bug.cgi?id=25852">25852</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>operation on bit-fields shall yield results reduced to bit-field size
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.7
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>konstantin.vladimirov@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=15468" name="attach_15468" title="bitfield reproduction">attachment 15468</a> <a href="attachment.cgi?id=15468&action=edit" title="bitfield reproduction">[details]</a></span>
bitfield reproduction

The test (attached) is taken from gcc dejagnu and minimized. Clang 3.7 yields:

  %bf.load = load i64, i64* bitcast ({ i8, i8, i8, i8, i8, [3 x i8], i8, i8,
i8, i8, i8, [3 x i8], i8, i8, i8, i8, i8, i8, [2 x i8] }* @a to i64*), align 8
  %bf.clear = and i64 %bf.load, 8589934591
  %mul = mul i64 %bf.clear, %bf.clear
  %cmp = icmp eq i64 %mul, 0                      
  br i1 %cmp, label %if.end, label %if.then

But after multiplication result should be casted to bitfield type, i.e. 33-bit.
Compare to GCC gimple:

  <unnamed-unsigned:33> D.2209D.2209;
  <unnamed-unsigned:33> D.2208D.2208;

<bb 2>:
  D.2208D.2208_1 = a.u33;
  D.2208D.2208_2 = a.u33;
  D.2209D.2209_3 = D.2208D.2208_2 * D.2208D.2208_2;
  if (D.2209D.2209_3 != 0)
    goto <bb 3>;
  else
    goto <bb 4>;

Which is correct.

Please fix this.</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>