[PATCH] D96945: [InstCombine] Add simplification of two logical and/ors

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 7 03:51:47 PST 2021


aqjune marked 2 inline comments as done.
aqjune added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp:2640
+        match(FalseVal, m_c_LogicalOr(m_Specific(CondVal), m_Value(B))))
+      return replaceOperand(SI, 2, B);
+
----------------
nikic wrote:
> What currently happens for something like `a ? (a | b) : false`? I assume it doesn't get folded?
No, it doesn't get folded.
That being said, I think it is better to simply propagate true/false to select operands, e.g.
`a ? (a | b) : false` -> `a ? (true | b) : false` -> `a ? b : false`. I'll update this patch to do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96945



More information about the llvm-commits mailing list