[llvm-branch-commits] [llvm] AMDGPU: Replace insertelement poison with insertelement undef (PR #130896)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Mar 11 22:50:48 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)' e1c6682fda904a2728a92e749ebcf01c35e2fa64 4515e4fe5873cc7069d3900e536f95518db81051 llvm/test/CodeGen/AMDGPU/add3.ll llvm/test/CodeGen/AMDGPU/amdpal_scratch_mergedshader.ll llvm/test/CodeGen/AMDGPU/any_extend_vector_inreg.ll llvm/test/CodeGen/AMDGPU/anyext.ll llvm/test/CodeGen/AMDGPU/bf16-conversions.ll llvm/test/CodeGen/AMDGPU/bfi_nested.ll llvm/test/CodeGen/AMDGPU/big_alu.ll llvm/test/CodeGen/AMDGPU/bug-deadlanes.ll llvm/test/CodeGen/AMDGPU/bug-v4f64-subvector.ll llvm/test/CodeGen/AMDGPU/build-vector-insert-elt-infloop.ll llvm/test/CodeGen/AMDGPU/build-vector-packed-partial-undef.ll llvm/test/CodeGen/AMDGPU/build_vector-r600.ll llvm/test/CodeGen/AMDGPU/build_vector.ll llvm/test/CodeGen/AMDGPU/bypass-div.ll llvm/test/CodeGen/AMDGPU/chain-hi-to-lo.ll llvm/test/CodeGen/AMDGPU/coalescer_remat.ll llvm/test/CodeGen/AMDGPU/collapse-endcf.ll llvm/test/CodeGen/AMDGPU/complex-folding.ll llvm/test/CodeGen/AMDGPU/cube.ll llvm/test/CodeGen/AMDGPU/cvt_f32_ubyte.ll llvm/test/CodeGen/AMDGPU/dagcomb-shuffle-vecextend-non2.ll llvm/test/CodeGen/AMDGPU/dagcombiner-bug-illegal-vec4-int-to-fp.ll llvm/test/CodeGen/AMDGPU/dead-machine-elim-after-dead-lane.ll llvm/test/CodeGen/AMDGPU/debug-value.ll llvm/test/CodeGen/AMDGPU/debug-value2.ll llvm/test/CodeGen/AMDGPU/divergence-driven-abs.ll llvm/test/CodeGen/AMDGPU/divergence-driven-buildvector.ll llvm/test/CodeGen/AMDGPU/ds-combine-with-dependence.ll llvm/test/CodeGen/AMDGPU/ds_read2.ll llvm/test/CodeGen/AMDGPU/ds_read2_superreg.ll llvm/test/CodeGen/AMDGPU/ds_write2.ll llvm/test/CodeGen/AMDGPU/extract-subvector-equal-length.ll llvm/test/CodeGen/AMDGPU/extract-vector-elt-build-vector-combine.ll llvm/test/CodeGen/AMDGPU/fcanonicalize-elimination.ll llvm/test/CodeGen/AMDGPU/flat-offset-bug.ll llvm/test/CodeGen/AMDGPU/floor.ll llvm/test/CodeGen/AMDGPU/fmac.sdwa.ll llvm/test/CodeGen/AMDGPU/fmad-formation-fmul-distribute-denormal-mode.ll llvm/test/CodeGen/AMDGPU/fmad.ll llvm/test/CodeGen/AMDGPU/fmax.ll llvm/test/CodeGen/AMDGPU/fmin.ll llvm/test/CodeGen/AMDGPU/fneg-combines.f16.ll llvm/test/CodeGen/AMDGPU/fneg-combines.ll llvm/test/CodeGen/AMDGPU/fneg-combines.new.ll llvm/test/CodeGen/AMDGPU/frame-index-elimination.ll llvm/test/CodeGen/AMDGPU/function-returns.ll llvm/test/CodeGen/AMDGPU/global-load-saddr-to-vaddr.ll llvm/test/CodeGen/AMDGPU/global-saddr-load.ll llvm/test/CodeGen/AMDGPU/image-schedule.ll llvm/test/CodeGen/AMDGPU/indirect-addressing-si.ll llvm/test/CodeGen/AMDGPU/input-mods.r600.ll llvm/test/CodeGen/AMDGPU/insert_vector_dynelt.ll llvm/test/CodeGen/AMDGPU/insert_vector_elt.ll llvm/test/CodeGen/AMDGPU/jump-address.ll llvm/test/CodeGen/AMDGPU/kcache-fold.ll llvm/test/CodeGen/AMDGPU/lds-bounds.ll llvm/test/CodeGen/AMDGPU/lds-dma-waits.ll llvm/test/CodeGen/AMDGPU/lds-misaligned-bug.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.image.nsa.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.intersect_ray.ll llvm/test/CodeGen/AMDGPU/llvm.amdgcn.udot2.ll llvm/test/CodeGen/AMDGPU/llvm.pow.ll llvm/test/CodeGen/AMDGPU/llvm.r600.cube.ll llvm/test/CodeGen/AMDGPU/load-hi16.ll llvm/test/CodeGen/AMDGPU/load-input-fold.ll llvm/test/CodeGen/AMDGPU/load-lo16.ll llvm/test/CodeGen/AMDGPU/loop-live-out-copy-undef-subrange.ll llvm/test/CodeGen/AMDGPU/lower-work-group-id-intrinsics-hsa.ll llvm/test/CodeGen/AMDGPU/lower-work-group-id-intrinsics-pal.ll llvm/test/CodeGen/AMDGPU/mad-mix-hi.ll llvm/test/CodeGen/AMDGPU/mad_uint24.ll llvm/test/CodeGen/AMDGPU/max-literals.ll llvm/test/CodeGen/AMDGPU/memory_clause.ll llvm/test/CodeGen/AMDGPU/merge-store-crash.ll llvm/test/CodeGen/AMDGPU/mfma-loop.ll llvm/test/CodeGen/AMDGPU/nsa-reassign.ll llvm/test/CodeGen/AMDGPU/operand-folding.ll llvm/test/CodeGen/AMDGPU/pack.v2f16.ll llvm/test/CodeGen/AMDGPU/pack.v2i16.ll llvm/test/CodeGen/AMDGPU/packed-fp32.ll llvm/test/CodeGen/AMDGPU/packed-op-sel.ll llvm/test/CodeGen/AMDGPU/predicate-dp4.ll llvm/test/CodeGen/AMDGPU/ps-shader-arg-count.ll llvm/test/CodeGen/AMDGPU/pv-packing.ll llvm/test/CodeGen/AMDGPU/pv.ll llvm/test/CodeGen/AMDGPU/r600-encoding.ll llvm/test/CodeGen/AMDGPU/r600-export-fix.ll llvm/test/CodeGen/AMDGPU/r600-infinite-loop-bug-while-reorganizing-vector.ll llvm/test/CodeGen/AMDGPU/r600cfg.ll llvm/test/CodeGen/AMDGPU/reassoc-scalar.ll llvm/test/CodeGen/AMDGPU/rv7x0_count3.ll llvm/test/CodeGen/AMDGPU/scalar_to_vector.ll llvm/test/CodeGen/AMDGPU/schedule-fs-loop-nested-if.ll llvm/test/CodeGen/AMDGPU/schedule-fs-loop-nested.ll llvm/test/CodeGen/AMDGPU/schedule-fs-loop.ll llvm/test/CodeGen/AMDGPU/schedule-if-2.ll llvm/test/CodeGen/AMDGPU/schedule-if.ll llvm/test/CodeGen/AMDGPU/schedule-vs-if-nested-loop-failure.ll llvm/test/CodeGen/AMDGPU/schedule-vs-if-nested-loop.ll llvm/test/CodeGen/AMDGPU/scheduler-subrange-crash.ll llvm/test/CodeGen/AMDGPU/sdwa-peephole.ll llvm/test/CodeGen/AMDGPU/sgpr-copy-duplicate-operand.ll llvm/test/CodeGen/AMDGPU/shared-op-cycle.ll llvm/test/CodeGen/AMDGPU/si-sgpr-spill.ll llvm/test/CodeGen/AMDGPU/si-triv-disjoint-mem-access.ll llvm/test/CodeGen/AMDGPU/si-vector-hang.ll llvm/test/CodeGen/AMDGPU/skip-promote-alloca-vector-users.ll llvm/test/CodeGen/AMDGPU/smfmac_no_agprs.ll llvm/test/CodeGen/AMDGPU/sminmax.ll llvm/test/CodeGen/AMDGPU/sminmax.v2i16.ll llvm/test/CodeGen/AMDGPU/smrd.ll llvm/test/CodeGen/AMDGPU/spill-vector-superclass.ll llvm/test/CodeGen/AMDGPU/split-scalar-i64-add.ll llvm/test/CodeGen/AMDGPU/splitkit-getsubrangeformask.ll llvm/test/CodeGen/AMDGPU/sram-ecc-default.ll llvm/test/CodeGen/AMDGPU/subreg-coalescer-crash.ll llvm/test/CodeGen/AMDGPU/subreg-coalescer-undef-use.ll llvm/test/CodeGen/AMDGPU/subreg-eliminate-dead.ll llvm/test/CodeGen/AMDGPU/swizzle-export.ll llvm/test/CodeGen/AMDGPU/tex-clause-antidep.ll llvm/test/CodeGen/AMDGPU/texture-input-merge.ll llvm/test/CodeGen/AMDGPU/trunc-combine.ll llvm/test/CodeGen/AMDGPU/undefined-subreg-liverange.ll llvm/test/CodeGen/AMDGPU/unigine-liveness-crash.ll llvm/test/CodeGen/AMDGPU/unpack-half.ll llvm/test/CodeGen/AMDGPU/v_pack.ll llvm/test/CodeGen/AMDGPU/v_sat_pk_u8_i16.ll llvm/test/CodeGen/AMDGPU/vector-legalizer-divergence.ll llvm/test/CodeGen/AMDGPU/vector_shuffle.packed.ll llvm/test/CodeGen/AMDGPU/vgpr-spill-emergency-stack-slot-compute.ll llvm/test/CodeGen/AMDGPU/vgpr-spill-emergency-stack-slot.ll llvm/test/CodeGen/AMDGPU/widen-vselect-and-mask.ll llvm/test/CodeGen/AMDGPU/wqm-gfx11.ll llvm/test/CodeGen/AMDGPU/xor3.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
 - llvm/test/CodeGen/AMDGPU/subreg-coalescer-undef-use.ll
 - llvm/test/CodeGen/AMDGPU/undefined-subreg-liverange.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/130896


More information about the llvm-branch-commits mailing list