llvm-project/llvm/test/Transforms/LoopVectorize/X86
Juneyoung Lee 9d70dbdc2b [InstCombine] use poison as placeholder for undemanded elems
Currently undef is used as a don’t-care vector when constructing a vector using a series of insertelement.
However, this is problematic because undef isn’t undefined enough.
Especially, a sequence of insertelement can be optimized to shufflevector, but using undef as its placeholder makes shufflevector a poison-blocking instruction because undef cannot be optimized to poison.
This makes a few straightforward optimizations incorrect, such as:

```
;  https://bugs.llvm.org/show_bug.cgi?id=44185

define <4 x float> @insert_not_undef_shuffle_translate_commute(float %x, <4 x float> %y, <4 x float> %q) {
  %xv = insertelement <4 x float> %q, float %x, i32 2
  %r = shufflevector <4 x float> %y, <4 x float> %xv, <4 x i32> { 0, 6, 2, undef }
  ret <4 x float> %r ; %r[3] is undef
}
=>
define <4 x float> @insert_not_undef_shuffle_translate_commute(float %x, <4 x float> %y, <4 x float> %q) {
  %r = insertelement <4 x float> %y, float %x, i32 1
  ret <4 x float> %r ; %r[3] = %y[3], incorrect if %y[3] = poison
}

Transformation doesn't verify!
ERROR: Target is more poisonous than source
```

I’d like to suggest
1. Using poison as insertelement’s placeholder value (IRBuilder::CreateVectorSplat should be patched too)
2. Updating shufflevector’s semantics to return poison element if mask is undef

Note that poison is currently lowered into UNDEF in SelDag, so codegen part is okay.
m_Undef() matches PoisonValue as well, so existing optimizations will still fire.

The only concern is hidden miscompilations that will go incorrect when poison constant is given.
A conservative way is copying all tests having `insertelement undef` & replacing it with `insertelement poison` & run Alive2 on it, but it will create many tests and people won’t like it. :(

Instead, I’ll simply locally maintain the tests and run Alive2.
If there is any bug found, I’ll report it.

Relevant links: https://bugs.llvm.org/show_bug.cgi?id=43958 , http://lists.llvm.org/pipermail/llvm-dev/2019-November/137242.html

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D93586
2020-12-28 08:58:15 +09:00
..
already-vectorized.ll [test][NPM] Fix already-vectorized.ll under NPM 2020-10-19 13:11:13 -07:00
avx1.ll
avx512.ll
consecutive-ptr-cg-bug.ll
consecutive-ptr-uniforms.ll [test] Fix Transforms/LoopVectorize under NPM 2020-12-07 21:48:21 -08:00
constant-fold.ll
constant-vector-operand.ll
conversion-cost.ll
cost-model-assert.ll [LoopVec] Support non-instructions as argument to uniform mem ops 2020-12-03 14:51:44 -08:00
cost-model.ll
float-induction-x86.ll [SimplifyCFG] TryToSimplifyUncondBranchFromEmptyBlock() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
fneg-cost.ll
force-ifcvt.ll
fp32_to_uint32-cost-model.ll
fp64_to_uint32-cost-model.ll
fp80-widest-type.ll
fp_to_sint8-cost-model.ll
funclet.ll
gather-cost.ll
gather-vs-interleave.ll
gather_scatter.ll [LV] Precommit test for PR48429. 2020-12-11 19:56:48 +00:00
gcc-examples.ll
illegal-parallel-loop-uniform-write.ll
imprecise-through-phis.ll [LoopUtils] Fix neutral value for vector.reduce.fadd 2020-10-29 21:45:13 +01:00
int128_no_gather.ll
interleave_short_tc.ll
interleaved-accesses-large-gap.ll
interleaved-accesses-waw-dependency.ll
interleaving.ll [LoopVectorize] Remove unused check-prefixes 2020-11-09 12:18:20 +00:00
invariant-load-gather.ll [InstCombine] use poison as placeholder for undemanded elems 2020-12-28 08:58:15 +09:00
invariant-store-vectorization.ll [LV] Epilogue Vectorization with Optimal Control Flow - Default Enablement 2020-12-07 14:29:36 -05:00
libm-vector-calls-VF2-VF8.ll Initial support for vectorization using Libmvec (GLIBC vector math library) 2020-10-22 16:01:39 -04:00
libm-vector-calls-finite.ll Initial support for vectorization using Libmvec (GLIBC vector math library) 2020-10-22 16:01:39 -04:00
libm-vector-calls.ll Initial support for vectorization using Libmvec (GLIBC vector math library) 2020-10-22 16:01:39 -04:00
lit.local.cfg
load-deref-pred.ll Use deref facts derived from minimum object size of allocations 2020-12-03 15:01:14 -08:00
masked_load_store.ll [LV] Epilogue Vectorization with Optimal Control Flow - Default Enablement 2020-12-07 14:29:36 -05:00
max-mstore.ll
metadata-enable.ll [NPM][opt] Run -O# after other passes in legacy PM compatibility mode 2020-10-19 11:48:44 -07:00
min-trip-count-switch.ll
mul_slm_16bit.ll
no-vector.ll
no_fpmath.ll
no_fpmath_with_hotness.ll
nontemporal.ll
optsize.ll [LV] Tail folded inloop reductions. 2020-10-11 16:58:34 +01:00
outer_loop_test1_no_explicit_vect_width.ll
parallel-loops-after-reg2mem.ll
parallel-loops.ll
powof2div.ll
pr23997.ll [LAA] Use DL to get element size for bound computation. 2020-10-07 18:57:07 +01:00
pr34438.ll [TEST]Autogenerate test checks, NFC. 2020-12-04 11:01:58 -08:00
pr35432.ll [llvm][mlir] Promote the experimental reduction intrinsics to be first class intrinsics. 2020-10-07 10:36:44 -07:00
pr36524.ll [LV] Collect dead induction truncates 2020-10-08 08:28:58 +01:00
pr39160.ll
pr42674.ll [SimplifyCFG] MergeBlockIntoPredecessor() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
propagate-metadata.ll
ptr-indvar-crash.ll
rauw-bug.ll
reduction-crash.ll
reduction-fastmath.ll [LoopUtils] Fix neutral value for vector.reduce.fadd 2020-10-29 21:45:13 +01:00
reduction-small-size.ll
redundant-vf2-cost.ll
reg-usage-debug.ll
reg-usage.ll [test] Fix reg-usage.ll under NPM 2020-12-20 15:41:29 -08:00
register-assumption.ll
scatter_crash.ll
slm-no-vectorize.ll
small-size.ll [LoopVectorize] regenerate test checks; NFC 2020-11-12 17:15:46 -05:00
strided_load_cost.ll [llvm][mlir] Promote the experimental reduction intrinsics to be first class intrinsics. 2020-10-07 10:36:44 -07:00
struct-store.ll
svml-calls-finite.ll SVML support for log10, sqrt 2020-09-15 17:29:44 -07:00
svml-calls.ll Revert SVML support for sqrt 2020-10-05 08:13:11 -07:00
tail_folding_and_assume_safety.ll
tail_loop_folding.ll [LV] Tail folded inloop reductions. 2020-10-11 16:58:34 +01:00
tripcount.ll
uint64_to_fp64-cost-model.ll
uniform-phi.ll
uniform_load.ll
uniform_mem_op.ll [LoopVec] Support non-instructions as argument to uniform mem ops 2020-12-03 14:51:44 -08:00
uniformshift.ll
unroll-pm.ll
unroll-small-loops.ll
unroll_selection.ll
veclib-calls.ll [test] Add -inject-tli-mapping to -loop-vectorize -vector-library tests 2020-08-25 11:55:11 -07:00
vect.omp.force.ll
vect.omp.force.small-tc.ll [LV] Tail folded inloop reductions. 2020-10-11 16:58:34 +01:00
vector-scalar-select-cost.ll
vector_max_bandwidth.ll
vector_ptr_load_store.ll
vectorization-remarks-loopid-dbg.ll
vectorization-remarks-missed.ll [NPM][test] Fix some LoopVectorize tests under NPM 2020-10-19 12:05:37 -07:00
vectorization-remarks-profitable.ll
vectorization-remarks.ll
vectorize-only-for-real.ll
x86-interleaved-accesses-masked-group.ll [SimplifyCFG] TryToSimplifyUncondBranchFromEmptyBlock() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
x86-pr39099.ll
x86-predication.ll [SimplifyCFG] TryToSimplifyUncondBranchFromEmptyBlock() already knows how to preserve DomTree 2020-12-17 01:03:49 +03:00
x86_fp80-interleaved-access.ll
x86_fp80-vector-store.ll