[PATCH] D42986: [TargetLowering] try to create -1 constant operand for math ops via demanded bits

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 7 08:01:32 PST 2018


spatel added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/TargetLowering.cpp:1246
+      SDValue Neg1 = TLO.DAG.getAllOnesConstant(dl, VT);
+      SDValue NewMath = TLO.DAG.getNode(Op.getOpcode(), dl, VT, Op0, Neg1);
+      return TLO.CombineTo(Op, NewMath);
----------------
craig.topper wrote:
> Do we need to do anything with NSW/NUW flags?
Good question. I saw the block above this and was wondering why it needed to explicitly disable those flags. It's because if we don't manually disable those flags, getNode() may return an existing node that has the flags set. That's scary...

The new math op in this case can't guarantee nsw/nuw, so yes, I think we need to explicitly disable those.


https://reviews.llvm.org/D42986





More information about the llvm-commits mailing list