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 (take 2) #59554

Closed
nikic opened this issue Dec 16, 2022 · 9 comments · Fixed by llvm/llvm-project-release-prs#222
Closed

TypePromotion produces invalid IR (take 2) #59554

nikic opened this issue Dec 16, 2022 · 9 comments · Fixed by llvm/llvm-project-release-prs#222
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] llvm:codegen release:backport release:merged

Comments

@nikic
Copy link
Contributor

nikic commented Dec 16, 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) {
  %arg.ext = zext i8 %arg to i64
  %trunc = trunc i64 %arg.ext to i3
  %switch.tableidx = xor i3 %trunc, 1
  %switch.maskindex = zext i3 %trunc to i8
  %switch.lobit = icmp ne i8 %switch.maskindex, 0
  ret i1 %switch.lobit
}

Results in a verifier error:

Both operands to a binary operator are not of the same type!
  %switch.tableidx = xor i64 %1, i32 1
in function test

The produced IR looks as follows:

define i1 @test(i8 %arg) {
  %arg.ext = zext i8 %arg to i64
  %1 = and i64 %arg.ext, 7
  %switch.tableidx = xor i64 %1, i32 1
  %2 = trunc i64 %1 to i32
  %switch.lobit = icmp ne i32 %2, 0
  ret i1 %switch.lobit
}

The symptoms here are similar to #58843, but the fix for that one did not fix this case.

@nikic nikic added backend:AArch64 crash Prefer [crash-on-valid] or [crash-on-invalid] labels Dec 16, 2022
@llvmbot
Copy link
Member

llvmbot commented Dec 16, 2022

@llvm/issue-subscribers-backend-aarch64

@nikic
Copy link
Contributor Author

nikic commented Dec 16, 2022

cc @bcl5980, as you worked on the previous fix.

@bcl5980
Copy link
Contributor

bcl5980 commented Jan 3, 2023

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

@bcl5980 bcl5980 closed this as completed in a0b470c Jan 3, 2023
nikic pushed a commit to rust-lang/llvm-project that referenced this issue Jan 3, 2023
…ate type is not extend type

If the src type is not extend type, after convert the truncate to and we need to truncate the and also to make sure the all user is legal.

The old fix D137613 doesn't work when the truncate convert to and have the other users. So this time I try to add the truncate after and to avoid all these potential issues.

Fix: llvm#59554

Reviewed By: samparker

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

(cherry picked from commit a0b470c)
@nikic nikic added this to the LLVM 15.0.7 Release milestone Jan 5, 2023
@nikic
Copy link
Contributor Author

nikic commented Jan 5, 2023

/cherry-pick a0b470c

@llvm llvm deleted a comment from llvmbot Jan 5, 2023
@EugeneZelenko EugeneZelenko reopened this Jan 5, 2023
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Jan 5, 2023
@nikic nikic moved this from Needs Triage to Needs Pull Request in LLVM Release Status Jan 5, 2023
@llvmbot
Copy link
Member

llvmbot commented Jan 5, 2023

/branch llvm/llvm-project-release-prs/issue59554

@nikic nikic moved this from Needs Pull Request to Needs Review in LLVM Release Status Jan 5, 2023
@llvmbot
Copy link
Member

llvmbot commented Jan 5, 2023

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

@nikic
Copy link
Contributor Author

nikic commented Jan 5, 2023

Adding this as a potential backport, as multiple people have hit this issue with Rust on AArch64.

@nikic nikic moved this from Needs Review to Needs Merge in LLVM Release Status Jan 9, 2023
@tstellar
Copy link
Collaborator

Is this a regression?

@nikic
Copy link
Contributor Author

nikic commented Jan 10, 2023

It looks like the TypePromotion issue occurs with opt-14 as well, though we have only started seeing it in end-to-end compiles with LLVM 15.

tstellar pushed a commit that referenced this issue Jan 10, 2023
…ate type is not extend type

If the src type is not extend type, after convert the truncate to and we need to truncate the and also to make sure the all user is legal.

The old fix D137613 doesn't work when the truncate convert to and have the other users. So this time I try to add the truncate after and to avoid all these potential issues.

Fix: #59554

Reviewed By: samparker

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

(cherry picked from commit a0b470c)
@nikic nikic moved this from Needs Merge to Done in LLVM Release Status Jan 10, 2023
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