<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 - Loading a vector of i1 loads the wrong value"
   href="https://bugs.llvm.org/show_bug.cgi?id=49942">49942</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Loading a vector of i1 loads the wrong value
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Core LLVM classes
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>malle@umich.edu
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This program:

```
@useFlag = private global <4 x i1> <i1 true, i1 true, i1 true, i1 true>


define i32 @get(i32 %arg)  {
    %ld = load <4 x i1>, <4 x i1>* @useFlag
    %zx = zext <4 x i1> %ld to <4 x i32>
    %ee = extractelement <4 x i32> %zx, i32 %arg
    ret i32 %ee
}

define i32 @main() {
  %g = call i32 @get(i32 2)
  ret i32 %g
}
```

will return 0.  I'd expect it to return 1 since it should load i1 true and then
zext that to i32 1.

Note that if you `get(i32 0)` then it returns 1 as expected.  Also, with -O3
this returns 1 correctly since the load is optimized out.

Tested with:

```
$ clang-10 --version
clang version 10.0.0
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
```

Sorry if this is a duplicate! I found some related notes on lists.llvm.org, but
not a bug report.</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>