[PATCH] D49837: [SelectionDAG] Handle unary SelectPatternFlavor for ABS case in SelectionDAGBuilder::visitSelect.

Ivan Kulagin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 01:32:11 PDT 2018


ikulagin added a comment.

In https://reviews.llvm.org/D49837#1221997, @RKSimon wrote:

> @ikulagin You might want to look at https://reviews.llvm.org/D26357 which was my old attempt to add an Intrinsic::abs IR intrinsic - you might be able to reuse some of the legalizers from that?


Thank you for that differential. I'll use some of the legalizers.



================
Comment at: lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp:2147
+
+  Hi = DAG.getNode(ISD::ABS, dl, OpType, Tmp);
+  // Lo = Hi==abs(Hi) ? Lo : 0 - Lo;
----------------
craig.topper wrote:
> Isn't this wrong if the value of high is 0x80000000? The absolute value of that would be 0x80000000 which would cause us to leave the low bits unchanged. But if the full value is 0x80000000_00000001 then the absolute value should be 0x7fffffff_ffffffff.
I'm sorry for the late response. Yes, this is wrong. I left out the case when the low/high parts contain values that are greater/smaller than the MAX/MIN for the given number of bits. I will redo it.


Repository:
  rL LLVM

https://reviews.llvm.org/D49837





More information about the llvm-commits mailing list