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 transformation: (undef u>> a) ^ -1 -> undef >> a, when a != 0 #44792

Closed
nunoplopes opened this issue Apr 6, 2020 · 3 comments
Closed
Labels
bugzilla Issues migrated from bugzilla miscompilation

Comments

@nunoplopes
Copy link
Member

Bugzilla Link 45447
Resolution FIXED
Resolved on Oct 23, 2020 18:33
Version trunk
OS All
Blocks #47292
CC @aqjune,@LebedevRI,@RKSimon,@regehr,@rotateright
Fixed by commit(s) 812970e

Extended Description

Test: Transforms/InstCombine/vector-xor.ll
Summary: (undef u>> a) ^ -1 always leaves top bits as 1 when a > 0. However 'undef >> a' can leave top bits as 0 or 1, depending on the sign bit of undef.

define <4 x i32> @​test_v4i32_not_lshr_nonnegative_const_undef(<4 x i32> %a0) {
%1 = lshr <4 x i32> { 3, 5, undef, 9 }, %a0
%2 = xor <4 x i32> { 4294967295, 4294967295, 4294967295, undef }, %1
ret <4 x i32> %2
}
=>
define <4 x i32> @​test_v4i32_not_lshr_nonnegative_const_undef(<4 x i32> %a0) {
%1 = ashr <4 x i32> { 4294967292, 4294967290, undef, 4294967286 }, %a0
ret <4 x i32> %1
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
<4 x i32> %a0 = < #x00000000 (0), #xfffffffe (4294967294, -2), #x0000001f (31), #xfffffffe (4294967294, -2) >

Source:
<4 x i32> %1 = < #x00000003 (3), poison, #x00000000 (0) [based on undef value], poison >
<4 x i32> %2 = < #xfffffffc (4294967292, -4), poison, #xffffffff (4294967295, -1), poison >

Target:
<4 x i32> %1 = < #xfffffffc (4294967292, -4), poison, #x00000000 (0), poison >
Source value: < #xfffffffc (4294967292, -4), poison, #xffffffff (4294967295, -1), poison >
Target value: < #xfffffffc (4294967292, -4), poison, #x00000000 (0), poison >

https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=2009353267698970&test=Transforms%2FInstCombine%2Fvector-xor.ll

@rotateright
Copy link
Contributor

Patch proposal:
https://reviews.llvm.org/D77739

@rotateright
Copy link
Contributor

@aqjune
Copy link
Contributor

aqjune commented Nov 27, 2021

mentioned in issue #47292

@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

3 participants