[llvm-branch-commits] [llvm] AMDGPU: Replace tests using undef in shufflevector with poison (PR #130899)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 11 23:06:24 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {undef deprecator}-->


:warning: undef deprecator found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' 3a308651bb8da4521e8769651f860325a05eb4cf 66846e5c71dc3b8881a48099d0d864bcf57e79de llvm/test/CodeGen/AMDGPU/GlobalISel/bug-legalization-artifact-combiner-dead-def.ll llvm/test/CodeGen/AMDGPU/GlobalISel/insertelement.ll llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.sdot2.ll llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.udot2.ll llvm/test/CodeGen/AMDGPU/GlobalISel/trunc.ll llvm/test/CodeGen/AMDGPU/GlobalISel/wmma-gfx12-w32-f16-f32-matrix-modifiers.ll llvm/test/CodeGen/AMDGPU/GlobalISel/wmma-gfx12-w64-f16-f32-matrix-modifiers.ll llvm/test/CodeGen/AMDGPU/adjust-writemask-invalid-copy.ll llvm/test/CodeGen/AMDGPU/amdgpu-codegenprepare-break-large-phis-heuristics.ll llvm/test/CodeGen/AMDGPU/amdpal_scratch_mergedshader.ll llvm/test/CodeGen/AMDGPU/buffer-rsrc-ptr-ops.ll llvm/test/CodeGen/AMDGPU/bug-deadlanes.ll llvm/test/CodeGen/AMDGPU/build-vector-packed-partial-undef.ll llvm/test/CodeGen/AMDGPU/call-argument-types.ll llvm/test/CodeGen/AMDGPU/clamp-modifier.ll llvm/test/CodeGen/AMDGPU/clamp.ll llvm/test/CodeGen/AMDGPU/coalesce-vgpr-alignment.ll llvm/test/CodeGen/AMDGPU/combine_vloads.ll llvm/test/CodeGen/AMDGPU/computeKnownBits-scalar-to-vector-crash.ll llvm/test/CodeGen/AMDGPU/concat_vectors.ll llvm/test/CodeGen/AMDGPU/dagcomb-shuffle-vecextend-non2.ll llvm/test/CodeGen/AMDGPU/dagcombine-fma-fmad.ll llvm/test/CodeGen/AMDGPU/dagcombiner-bug-illegal-vec4-int-to-fp.ll llvm/test/CodeGen/AMDGPU/debug-value.ll llvm/test/CodeGen/AMDGPU/debug-value2.ll llvm/test/CodeGen/AMDGPU/early-if-convert.ll llvm/test/CodeGen/AMDGPU/extract-subvector-16bit.ll llvm/test/CodeGen/AMDGPU/extract-subvector-equal-length.ll llvm/test/CodeGen/AMDGPU/extract-subvector.ll llvm/test/CodeGen/AMDGPU/extract_subvector_vec4_vec3.ll llvm/test/CodeGen/AMDGPU/fmac.sdwa.ll llvm/test/CodeGen/AMDGPU/fneg-modifier-casting.ll llvm/test/CodeGen/AMDGPU/gfx-callable-argument-types.ll llvm/test/CodeGen/AMDGPU/greedy-reverse-local-assignment.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.image.d16.dim.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.image.sample.d16.dim.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.image.sample.dim.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.buffer.store.format.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.buffer.store.format.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.ptr.tbuffer.store.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.raw.tbuffer.store.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.struct.buffer.store.format.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.struct.ptr.buffer.store.format.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.struct.ptr.tbuffer.store.d16.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.struct.tbuffer.store.d16.ll llvm/test/CodeGen/AMDGPU/load-local-redundant-copies.ll llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll llvm/test/CodeGen/AMDGPU/mad-mix.ll llvm/test/CodeGen/AMDGPU/mul_int24.ll llvm/test/CodeGen/AMDGPU/packed-fp32.ll llvm/test/CodeGen/AMDGPU/packed-op-sel.ll llvm/test/CodeGen/AMDGPU/permute_i8.ll llvm/test/CodeGen/AMDGPU/reduction.ll llvm/test/CodeGen/AMDGPU/scalar_to_vector.ll llvm/test/CodeGen/AMDGPU/simplify-libcalls.ll llvm/test/CodeGen/AMDGPU/split-arg-dbg-value.ll llvm/test/CodeGen/AMDGPU/trunc-store-vec-i16-to-i8.ll llvm/test/CodeGen/AMDGPU/vector_shuffle.packed.ll llvm/test/CodeGen/AMDGPU/vgpr-liverange-ir.ll llvm/test/CodeGen/AMDGPU/wmma-gfx12-w32-f16-f32-matrix-modifiers.ll llvm/test/CodeGen/AMDGPU/wmma-gfx12-w64-f16-f32-matrix-modifiers.ll llvm/test/CodeGen/AMDGPU/wmma_modifiers.ll
``````````

</details>


The following files introduce new uses of undef:
 - llvm/test/CodeGen/AMDGPU/build-vector-packed-partial-undef.ll
 - llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll

[Undef](https://llvm.org/docs/LangRef.html#undefined-values) is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields `undef`. You should use `poison` values for placeholders instead.

In tests, avoid using `undef` and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead.

For example, this is considered a bad practice:
```llvm
define void @fn() {
  ...
  br i1 undef, ...
}
```

Please use the following instead:
```llvm
define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}
```

Please refer to the [Undefined Behavior Manual](https://llvm.org/docs/UndefinedBehavior.html) for more information.



https://github.com/llvm/llvm-project/pull/130899


More information about the llvm-branch-commits mailing list