Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading a vector of i1 loads the wrong value #49286

Closed
Joemalle mannequin opened this issue Apr 13, 2021 · 1 comment
Closed

Loading a vector of i1 loads the wrong value #49286

Joemalle mannequin opened this issue Apr 13, 2021 · 1 comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen

Comments

@Joemalle
Copy link
Mannequin

Joemalle mannequin commented Apr 13, 2021

Bugzilla Link 49942
Version 10.0
OS All
Blocks #30613
CC @RKSimon,@Nuullll

Extended Description

This program:

@&#8203;useFlag = private global <4 x i1> <i1 true, i1 true, i1 true, i1 true>


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

define i32 @&#8203;main() {
  %g = call i32 @&#8203;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.

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 6, 2022

@llvm/issue-subscribers-clang-codegen

mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Vectors are defined to be tightly packed, regardless of the element
type.  The AsmPrinter didn't realize this, and was allocating extra
padding.

Fixes llvm/llvm-project#49286
Fixes llvm/llvm-project#53246
Fixes llvm/llvm-project#55522

Differential Revision: https://reviews.llvm.org/D129164
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen
Projects
None yet
Development

No branches or pull requests

2 participants