[all-commits] [llvm/llvm-project] 0b302b: [Transforms] Pre-commit test cases for CorrelatedV...

Dmitry Vasilyev via All-commits all-commits at lists.llvm.org
Tue Feb 22 12:12:18 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0b302be023388e7cec2daf680a3ea6718c6af53f
      https://github.com/llvm/llvm-project/commit/0b302be023388e7cec2daf680a3ea6718c6af53f
  Author: Dmitry Vassiliev <dvassiliev at accesssoftek.com>
  Date:   2022-02-23 (Wed, 23 Feb 2022)

  Changed paths:
    M llvm/test/Transforms/CorrelatedValuePropagation/basic.ll

  Log Message:
  -----------
  [Transforms] Pre-commit test cases for CorrelatedValuePropagation to handle both values of select
This is a pre-commit of test cases relevant for D119643.
CorrelatedValuePropagation should handle inverted select condition, but it does not yet.


  Commit: 90a3b310917031c802bb930626e85f067d53ea5b
      https://github.com/llvm/llvm-project/commit/90a3b310917031c802bb930626e85f067d53ea5b
  Author: Dmitry Vassiliev <dvassiliev at accesssoftek.com>
  Date:   2022-02-23 (Wed, 23 Feb 2022)

  Changed paths:
    M llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
    M llvm/test/Transforms/CorrelatedValuePropagation/basic.ll

  Log Message:
  -----------
  [Transforms] Enhance CorrelatedValuePropagation to handle both values of select

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.

Reviewed By: nikic, lebedev.ri

Differential Revision: https://reviews.llvm.org/D119643


Compare: https://github.com/llvm/llvm-project/compare/30053c1445e2...90a3b3109170


More information about the All-commits mailing list