[PATCH] D25135: [InstCombine] sub X, sext(bool Y) -> add X, zext(bool Y)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 12:01:37 PDT 2016
efriedma added inline comments.
================
Comment at: lib/Transforms/InstCombine/InstCombineAddSub.cpp:1648
+ // But ignore a 'sub nuw' because we can't transfer nuw to the add.
+ if (!I.hasNoUnsignedWrap() && match(Op1, m_SExt(m_Value(Y))) &&
+ Y->getType()->getScalarSizeInBits() == 1) {
----------------
I would favor dropping the nuw flag over keeping IR in a form that isn't canonical.
================
Comment at: test/Transforms/InstCombine/urem.ll:32
+; CHECK-NEXT: [[TMP1:%.*]] = zext i1 [[NOT_]] to i5
+; CHECK-NEXT: [[REM:%.*]] = add i5 [[TMP1]], %x
; CHECK-NEXT: ret i5 [[REM]]
----------------
For example, this seems better than "sub nuw i5 %x, %tmp".
https://reviews.llvm.org/D25135
More information about the llvm-commits
mailing list