[PATCH] D29587: [DAGCombiner] mulhi + 1 never overflow.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 15 13:44:05 PST 2017


efriedma added inline comments.


================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2781
+      (~N1Zero & 0x01) == ~N1Zero)
+    return OFK_Never;
+
----------------
deadalnix wrote:
> deadalnix wrote:
> > efriedma wrote:
> > > Another question: is there some reason to expect that N0 is the multiply, rather than N1?
> > The specific case I'm looking at is fma like construct on big ints. After legalization you end up with combination of adde and mulhi no the left hand side. But indeed, that's an option to do it the other way around.
> So i tried to do it both ways. I see no difference in any of my tests cases, but, on the other hand, I see no reason not to do it. What do you think ?
I don't really like duplicating the code like that... but I guess we need to do it that way to avoid calling computeKnownBits when we don't use the result?

You can probably construct a smaller testcase to trigger this; maybe something like `(uint64_t)(c == 0) + (((uint64_t)a * (uint64_t)b) >> 32)`, where a, b, and c are 32-bit integers.


https://reviews.llvm.org/D29587





More information about the llvm-commits mailing list