[PATCH] D157685: [SDAG] Don't transfer !range metadata without !noundef to SDAG (PR64589)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 01:18:06 PDT 2023


nikic created this revision.
nikic added reviewers: RKSimon, pengfei, goldstein.w.n, arsenm.
Herald added subscribers: StephenFan, kerbowa, steven.zhang, hiraditya, jvesely, nemanjai.
Herald added a project: All.
nikic requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

D141386 <https://reviews.llvm.org/D141386> changed the semantics of `!range` metadata to return poison on violation. If `!range` is combined with `!noundef`, violation is immediate UB instead, matching the old semantics.

In theory, these IR semantics should also carry over into SDAG. In practice, DAGCombine has at least one key transform that is invalid in the presence of poison, namely the conversion of logical and/or to bitwise and/or (https://github.com/llvm/llvm-project/blob/c7b537bf0923df05254f9fa4722b298eb8f4790d/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L11252). Ideally, we would fix this transform, but this will require substantial work to avoid codegen regressions.

In the meantime, avoid transferring !range metadata without !noundef, effectively restoring the old !range metadata semantics on the SDAG layer.

Fixes https://github.com/llvm/llvm-project/issues/64589.


https://reviews.llvm.org/D157685

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/test/CodeGen/AMDGPU/array-ptr-calc-i32.ll
  llvm/test/CodeGen/AMDGPU/global-saddr-load.ll
  llvm/test/CodeGen/AMDGPU/load-range-metadata-assert.ll
  llvm/test/CodeGen/AMDGPU/load-range-metadata-sign-bits.ll
  llvm/test/CodeGen/PowerPC/BreakableToken-reduced.ll
  llvm/test/CodeGen/PowerPC/global-address-non-got-indirect-access.ll
  llvm/test/CodeGen/X86/pr12360.ll
  llvm/test/CodeGen/X86/pr48458.ll
  llvm/test/CodeGen/X86/pr48888.ll
  llvm/test/CodeGen/X86/pr64589.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157685.549280.patch
Type: text/x-patch
Size: 14712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230811/59f2c07e/attachment.bin>


More information about the llvm-commits mailing list