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

TypePromotion produces invalid IR #58843

Closed
nikic opened this issue Nov 7, 2022 · 6 comments · Fixed by llvm/llvm-project-release-prs#210
Closed

TypePromotion produces invalid IR #58843

nikic opened this issue Nov 7, 2022 · 6 comments · Fixed by llvm/llvm-project-release-prs#210
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:codegen release:backport release:merged

Comments

@nikic
Copy link
Contributor

nikic commented Nov 7, 2022

; RUN: opt -S -type-promotion < %s
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

define i1 @test(i8 %arg) {
  %ext1 = zext i8 %arg to i64
  %trunc = trunc i64 %ext1 to i3
  %ext2 = zext i3 %trunc to i8
  %cmp = icmp ne i8 %ext2, 0
  ret i1 %cmp
}

Results in a verifier error:

Type too small for ZExt
  %ext2 = zext i64 %1 to i32
in function test
LLVM ERROR: Broken function found, compilation aborted!

The produced IR looks as follows:

define i1 @test(i8 %arg) {
  %ext1 = zext i8 %arg to i64
  %1 = and i64 %ext1, 7
  %ext2 = zext i64 %1 to i32
  %cmp = icmp ne i32 %ext2, 0
  ret i1 %cmp
}
@nikic nikic added backend:AArch64 crash Prefer [crash-on-valid] or [crash-on-invalid] and removed new issue labels Nov 7, 2022
@llvmbot
Copy link
Member

llvmbot commented Nov 7, 2022

@llvm/issue-subscribers-backend-aarch64

@bcl5980
Copy link
Contributor

bcl5980 commented Nov 8, 2022

Should be a general issue. Only x64, riscv64 can pass the test.
https://godbolt.org/z/7Pxcj43cK

@bcl5980
Copy link
Contributor

bcl5980 commented Nov 8, 2022

Candidate patch:
https://reviews.llvm.org/D137613

@bcl5980 bcl5980 closed this as completed in 597f444 Nov 9, 2022
@nikic nikic reopened this Nov 9, 2022
@nikic nikic moved this from Needs Fix to Needs Pull Request in LLVM Release Status Nov 9, 2022
@nikic
Copy link
Contributor Author

nikic commented Nov 9, 2022

/cherry-pick 597f444

@llvmbot
Copy link
Member

llvmbot commented Nov 9, 2022

/branch llvm/llvm-project-release-prs/issue58843

llvmbot pushed a commit to llvm/llvm-project-release-prs that referenced this issue Nov 9, 2022
… larger

Fix: llvm/llvm-project#58843

Reviewed By: samtebbs

Differential Revision: https://reviews.llvm.org/D137613

(cherry picked from commit 597f444)
@nikic nikic moved this from Needs Pull Request to Needs Review in LLVM Release Status Nov 9, 2022
@llvmbot
Copy link
Member

llvmbot commented Nov 9, 2022

/pull-request llvm/llvm-project-release-prs#210

tstellar pushed a commit to llvm/llvm-project-release-prs that referenced this issue Nov 11, 2022
… larger

Fix: llvm/llvm-project#58843

Reviewed By: samtebbs

Differential Revision: https://reviews.llvm.org/D137613

(cherry picked from commit 597f444)
@tstellar tstellar moved this from Needs Review to Done in LLVM Release Status Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:codegen release:backport release:merged
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants