[PATCH] D76800: [InstCombine] Fix Incorrect fold of ashr+xor -> lshr w/ vectors
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 25 14:38:47 PDT 2020
spatel added a comment.
In D76800#1942204 <https://reviews.llvm.org/D76800#1942204>, @lebedev.ri wrote:
> What we need to do here is "define" undef to be 0.
>
> ----------------------------------------
> define <4 x i5> @test_v4i5_not_ashr_negative_const_undef(<4 x i5> %a0) {
> %0:
> %1 = ashr <4 x i5> { 29, 27, undef, 23 }, %a0
> %2 = xor <4 x i5> { 31, 31, 31, undef }, %1
> ret <4 x i5> %2
> }
> =>
> define <4 x i5> @test_v4i5_not_ashr_negative_const_undef(<4 x i5> %a0) {
> %0:
> %1 = lshr <4 x i5> { 2, 4, 0, 8 }, %a0
> ret <4 x i5> %1
> }
> Transformation seems to be correct!
>
> Summary:
> 1 correct transformations
> 0 incorrect transformations
> 0 Alive2 errors
>
>
> There was some utility for that already, but i don't recall how it's called..
Probably want this:
/// Some binary operators require special handling to avoid poison and undefined
/// behavior. If a constant vector has undef elements, replace those undefs with
/// identity constants if possible because those are always safe to execute.
/// If no identity constant exists, replace undef with some other safe constant.
static inline Constant *getSafeVectorConstantForBinop()
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76800/new/
https://reviews.llvm.org/D76800
More information about the llvm-commits
mailing list