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

Incorrect fold of ashr+xor -> lshr w/ vectors #43010

Closed
nunoplopes opened this issue Oct 13, 2019 · 2 comments
Closed

Incorrect fold of ashr+xor -> lshr w/ vectors #43010

nunoplopes opened this issue Oct 13, 2019 · 2 comments
Labels
bugzilla Issues migrated from bugzilla miscompilation

Comments

@nunoplopes
Copy link
Member

Bugzilla Link 43665
Resolution FIXED
Resolved on Mar 26, 2020 11:13
Version trunk
OS All
CC @ecnelises,@LebedevRI,@RKSimon,@regehr,@rotateright

Extended Description

The following test in Transforms/InstCombine/vector-xor.ll shows an incorrect transformation. I reproduce it here with a smaller vector size & bitwidth to make it easier to understand.
The issue is that "undef >> 4" is "ssss.sxyz" (s = sign bit), while "undef u>> 4" is "0000.xyzw", so it can produce the value "0000.1000", while ashr cannot. See details below:

define <2 x i8> @​test_v4i32_not_ashr_negative_const_undef(<2 x i8> %a0) {
%1 = ashr <2 x i8> { 251, undef }, %a0
%2 = xor <2 x i8> { 255, 255 }, %1
ret <2 x i8> %2
}
=>
define <2 x i8> @​test_v4i32_not_ashr_negative_const_undef(<2 x i8> %a0) {
%1 = lshr <2 x i8> { 4, undef }, %a0
ret <2 x i8> %1
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
<2 x i8> %a0 = < #x00 (0), #x04 (4) >

Source:
<2 x i8> %1 = < #xfb (251, -5), #x00 (0) [based on undef value] >
<2 x i8> %2 = < #x04 (4), #xff (255, -1) >

Target:
<2 x i8> %1 = < #x04 (4), #x08 (8) >
Source value: < #x04 (4), #xff (255, -1) >
Target value: < #x04 (4), #x08 (8) >

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 25, 2020

@llvmbot
Copy link
Collaborator

llvmbot commented Mar 26, 2020

7a89a5d

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla miscompilation
Projects
None yet
Development

No branches or pull requests

2 participants