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

miscompile from multiple backends #55484

Closed
regehr opened this issue May 15, 2022 · 6 comments
Closed

miscompile from multiple backends #55484

regehr opened this issue May 15, 2022 · 6 comments

Comments

@regehr
Copy link
Contributor

regehr commented May 15, 2022

here's a function:

define i32 @f(i32 %0) {
  %2 = lshr i32 %0, 8
  %3 = shl i32 %0, 8
  %4 = or i32 %2, %3
  %5 = trunc i32 %4 to i16
  %6 = sext i16 %5 to i32
  ret i32 %6
}

we believe that f(0x00800000) -> ffff8000 but the top-of-tree arm64, x86, and x86-64 backends are all emitting code which says that f(0x00800000) -> 0

Johns-MacBook-Pro:~ regehr$ llc -o - foo.ll
	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 12, 0
	.globl	_f                              ; -- Begin function f
	.p2align	2
_f:                                     ; @f
	.cfi_startproc
; %bb.0:
	rev	w8, w0
	asr	w0, w8, #16
	ret
	.cfi_endproc
                                        ; -- End function
.subsections_via_symbols
Johns-MacBook-Pro:~ regehr$ 

cc @ornata @nunoplopes @ryan-berger @nbushehri @zhengyang92 @aqjune @Hatsunespica

@llvmbot
Copy link
Collaborator

llvmbot commented May 15, 2022

@llvm/issue-subscribers-backend-aarch64

@llvmbot
Copy link
Collaborator

llvmbot commented May 15, 2022

@llvm/issue-subscribers-backend-x86

@llvmbot
Copy link
Collaborator

llvmbot commented May 15, 2022

@llvm/issue-subscribers-backend-risc-v

@topperc
Copy link
Collaborator

topperc commented May 15, 2022

I can reproduce this on RISC-V with Zbb as well.

@topperc topperc self-assigned this May 15, 2022
@topperc
Copy link
Collaborator

topperc commented May 15, 2022

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

@topperc
Copy link
Collaborator

topperc commented May 18, 2022

Fixed in 46eef76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants