[PATCH] D49919: [InstCombine] Fold Select with AND/OR condition

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 27 12:10:03 PDT 2018


lebedev.ri added a comment.

In general, looks ok, but i would like to see better test coverage
(the both test files should be identical other than `or` vs. `and` and `ne` vs. `eq`)

1. A positive test with `<2 x i32>` vector
2. Negative tests:
  - wrong (opposite) predicate (one and/or both, i.e. ideally 3 tests?)
  - Some other `TrueVal` of the select - a some new argument `%k`
  - Some other `FalseVal` of the select - a some new argument `%k`



================
Comment at: lib/Analysis/InstructionSimplify.cpp:102-106
+  if (BinOpCode == BinaryOperator::And) {
+    std::swap(TrueVal, FalseVal);
+  }
+
+  return TrueVal;
----------------
Hmm, ok, i think that would work too. https://rise4fun.com/Alive/wYX
But maybe
```
return BinOpCode == BinaryOperator::Or ? TrueVal : FalseVal;
```
to not anyone else wonder about this being done after the match.


https://reviews.llvm.org/D49919





More information about the llvm-commits mailing list