[PATCH] D110488: [InstCombine] Canonicalize ((X & -X) - 1) --> (~X & (X - 1)) (PR51784)

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 08:29:33 PDT 2022


spatel added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:1424
+    Constant *AllOnes = ConstantInt::getAllOnesValue(RHS->getType());
+    return BinaryOperator::CreateAnd(Builder.CreateXor(A, AllOnes),
+                                     Builder.CreateAdd(A, AllOnes));
----------------
xbolva00 wrote:
> Nondet output? Different evaluation order of args between compilers
Good catch - yeah, use local variables to ensure that the xor and add are inserted in a fixed order.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110488



More information about the llvm-commits mailing list