[PATCH] D60396: [InstCombine] sdiv exact flag fixup

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 05:23:28 PDT 2019


lebedev.ri added inline comments.


================
Comment at: llvm/trunk/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1696
     if (match(Op1, m_SDiv(m_Value(X), m_Constant(C))) && match(Op0, m_Zero()) &&
-        C->isNotMinSignedValue() && !C->isOneValue())
-      return BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(C));
+        C->isNotMinSignedValue() && !C->isOneValue()) {
+      auto *BO = BinaryOperator::CreateSDiv(X, ConstantExpr::getNeg(C));
----------------
Uhm.
So, this is not related to this patch specifically, but i think `isOneValue()` check is incorrect,
and //may// be causing miscompiles: https://godbolt.org/z/CmAslh <- i don't think `@test_exact_vec` should be folded?
I think you want to add a `isNotOneValue()`.
Also, is this fold valid for `undef` elements?

CC @spatel 


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60396





More information about the llvm-commits mailing list