LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 45481 - Can't remove insertelement undef
Summary: Can't remove insertelement undef
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords: miscompilation
Depends on:
Blocks:
 
Reported: 2020-04-09 02:03 PDT by Nuno Lopes
Modified: 2020-12-02 06:43 PST (History)
6 users (show)

See Also:
Fixed By Commit(s): 5486e00, 57f0eed


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Lopes 2020-04-09 02:03:34 PDT
Test: Transforms/InstSimplify/insertelement.ll
Summary: We can't remove insertelement undef to a vector, since it may be replacing a poison value.

define <4 x i32> @PR1286(<4 x i32> %A) {
  %B = insertelement <4 x i32> %A, i32 undef, i32 1
  ret <4 x i32> %B
}
=>
define <4 x i32> @PR1286(<4 x i32> %A) {
  ret <4 x i32> %A
}
Transformation doesn't verify!
ERROR: Target is more poisonous than source

Example:
<4 x i32> %A = < poison, poison, poison, poison >

Source:
<4 x i32> %B = < poison, undef, poison, poison >

Target:
Source value: < poison, undef, poison, poison >
Target value: < poison, poison, poison, poison >


Report: https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=ed3ac07d4817b221&test=Transforms%2FInstSimplify%2Finsertelement.ll
Comment 2 Mikael Holmén 2020-12-02 06:43:30 PST
(In reply to Sanjay Patel from comment #1)
> Removed the unsafe fold:
> https://github.com/llvm/llvm-project/commit/
> 5486e00dc3e3bb9969f1e8dbddfd18bb92c99e56
> 
> And added back a safe version:
> https://github.com/llvm/llvm-project/commit/
> 57f0eed98d02cd684c358a45f68e716179f4bfa3

I just wrote an issue about jump-threading not terminating after the above fixes:
 https://bugs.llvm.org/show_bug.cgi?id=48362