[PATCH] D62818: [InstCombine] Introduce fold for icmp pred (and X, (sh signbit, Y)), 0.

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 01:34:08 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp:1790-1792
+                     m_Value(V0),
+                     m_CombineAnd(m_LogicalShift(m_SignMask(), m_Value(V1)),
+                                  m_Value(Shift)))))) {
----------------
`m_Value(V0)` will always match, it's best to swap them.



================
Comment at: llvm/test/Transforms/InstCombine/onehot_merge.ll:18
 ;CHECK: @foo1_and
-;CHECK:  shl i32 1, %c1
-;CHECK-NEXT:  lshr i32 -2147483648, %c2
----------------
Can you please regenerate the original test?


================
Comment at: llvm/test/Transforms/InstCombine/onehot_merge.ll:18-23
+;CHECK:       [[TMP:%.*]] = shl i32 1, %c1
+;CHECK-NEXT:  [[TMP1:%.*]] = and i32 [[TMP]], %k
+;CHECK-NEXT:  icmp eq i32 [[TMP1]], 0
+;CHECK-NEXT:  [[TMP2:%.*]] = shl i32 %k, %c2
+;CHECK-NEXT:  icmp sgt i32 [[TMP2]], -1
+;CHECK-NEXT:  or i1
----------------
lebedev.ri wrote:
> Can you please regenerate the original test?
I'm not sure what's on the LHS of the diff, but ignoring the instruction count this looks like improvement to me.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62818





More information about the llvm-commits mailing list