[PATCH] D119643: [Transforms] Enhance CorrelatedValuePropagation to handle both values of select

Dmitry Vassiliev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 12 11:30:38 PST 2022


slydiman created this revision.
slydiman added reviewers: junparser, kazu, asavonic, krisb.
slydiman added a project: LLVM.
Herald added a subscriber: hiraditya.
slydiman requested review of this revision.
Herald added a subscriber: llvm-commits.

The "Correlated Value Propagation" pass was missing a case when handling select instructions. It was only handling the "false" constant value, while in NVPTX the select may have the condition (and thus the branches) inverted, for example:

  loop:
  	%phi = phi i32* [ %sel, %loop ], [ %x, %entry ]
  	%f = tail call i32* @f(i32* %phi)
  	%cmp1 = icmp ne i32* %f, %y
  	%sel = select i1 %cmp1, i32* %f, i32* null
  	%cmp2 = icmp eq i32* %sel, null
  	br i1 %cmp2, label %return, label %loop

But the select condition can be inverted:

  	%cmp1 = icmp eq i32* %f, %y
  	%sel = select i1 %cmp1, i32* null, i32* %f

The fix is to enhance "Correlated Value Propagation" to handle both branches of the select instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119643

Files:
  llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
  llvm/test/Transforms/CorrelatedValuePropagation/select_cond.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119643.408203.patch
Type: text/x-patch
Size: 3986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220212/ecf99150/attachment.bin>


More information about the llvm-commits mailing list