[PATCH] D77890: [ValueTracking] Implement isPoisonIf and canPushFreezeIntoOperands

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 13:31:13 PDT 2020


aqjune marked an inline comment as done.
aqjune added inline comments.


================
Comment at: llvm/lib/Analysis/ValueTracking.cpp:4646-4647
+  case Instruction::Select:
+  case Instruction::URem:
+  case Instruction::SRem:
+  case Instruction::ShuffleVector:
----------------
spatel wrote:
> Immediate undefined behavior (eg, sdiv %x, 0) is explicitly not poison?
> If correct, please note that in the documentation comment for this function, so there is no confusion.
> (There's existing code called "MightCreatePoisonOrUB" in instcombine, but I'm not sure if it can be changed to use this new analysis function.)
For MightCreatePoisonOrUB, we can use this function, but it can be broken if canCreatePoison uses deeper analysis.
You mean this optimization when M is given such that shufflevector can work as a vector select:
```
    // shuffle (op X, C0), (op Y, C1), M --> op (shuffle X, Y, M), C'
    // shuffle (op C0, X), (op C1, Y), M --> op C', (shuffle X, Y, M)
```
For example:
```
X = 0 & (freeze X0)
Y = 0 & (freeze Y0) // X and Y are 0
// canCreatePoison concluded that shl C0, X and shl C1, Y are safe
shuffle (shl C0, X), (shl C1, Y), undef
=>
shl C', (shufflevector X, Y, undef)
=>
shl C', undef
```
To make using canCreatePoison safe, M should not contain undef elements.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77890/new/

https://reviews.llvm.org/D77890





More information about the llvm-commits mailing list