[PATCH] D77868: [InstSimplify] fold select of bools using bitwise logic
    Roman Lebedev via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Mon Apr 13 10:12:24 PDT 2020
    
    
  
lebedev.ri accepted this revision.
lebedev.ri added a comment.
lg
================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:3983-3989
+  // select Cond, T, false --> Cond & T
+  if (match(F, m_ZeroInt()))
+    return SimplifyAndInst(Cond, T, Q);
+
+  // select Cond, true, F --> Cond | F
+  if (match(T, m_One()))
+    return SimplifyOrInst(Cond, F, Q);
----------------
I would recommend making this more obvious:
```
  // select Cond, T, false --> Cond & T
  if (match(F, m_ZeroInt()))
    if(Value* V = SimplifyAndInst(Cond, T, Q))
      return V;
  // select Cond, true, F --> Cond | F
  if (match(T, m_One()))
    if(Value* V = SimplifyOrInst(Cond, F, Q))
      return V;
```
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77868/new/
https://reviews.llvm.org/D77868
    
    
More information about the llvm-commits
mailing list