[PATCH] D45317: Canonicalization of the min/max patterns.

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 06:25:00 PDT 2018


spatel added inline comments.


================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2699
 
+  // Perform canonicalization of the following min/max pattern:
+  //
----------------
A better description would be something like:
Eliminate a bitwise 'not' op of 'not' min/max by inverting the min/max.


================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:2721
+      if (match(LHS, m_Not(m_Value(X)))) {
+        Value *NotY = Builder.CreateXor(RHS, AllOnes);
+        return SelectInst::Create(
----------------
Use CreateNot() to simplify code.


================
Comment at: test/Transforms/InstCombine/xor.ll:580
+; The tests 39-46 are related to the canonicalization:
+; https://rise4fun.com/Alive/lCN
+
----------------
Please remove the Alive link. If you want to include the text of the proof as a comment that's fine AFAIK.
See discussion here: https://reviews.llvm.org/D45108?id=141224#inline-396638


================
Comment at: test/Transforms/InstCombine/xor.ll:651-663
+define i32 @test44(i32 %x, i32 %y) {
+; CHECK-LABEL: @test44(
+; CHECK-NEXT:    [[TMP1:%.*]] = xor i32 [[Y:%.*]], -1
+; CHECK-NEXT:    [[TMP2:%.*]] = icmp ult i32 [[TMP1]], [[X:%.*]]
+; CHECK-NEXT:    [[RES:%.*]] = select i1 [[TMP2]], i32 [[X]], i32 [[TMP1]]
+; CHECK-NEXT:    ret i32 [[RES]]
+;
----------------
This is identical to test43? You may need to inhibit complexity-based operand canonicalization to test the pattern where the 'not' op is actually operand 1 of the compare; grep for 'thwart' in test/Transforms/InstCombine to see examples of that.


Repository:
  rL LLVM

https://reviews.llvm.org/D45317





More information about the llvm-commits mailing list