LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 49942 - Loading a vector of i1 loads the wrong value
Summary: Loading a vector of i1 loads the wrong value
Status: NEW
Alias: None
Product: libraries
Classification: Unclassified
Component: Core LLVM classes (show other bugs)
Version: 10.0
Hardware: PC All
: P enhancement
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 31265
  Show dependency tree
 
Reported: 2021-04-12 17:38 PDT by Joseph Malle
Modified: 2021-09-12 19:24 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Malle 2021-04-12 17:38:08 PDT
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.