[PATCH] D23007: [DAGCombiner] Better support for shifting large value type by constants
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 08:45:38 PDT 2016
t.p.northover added a comment.
Ah, of course. `undef` isn't unrestrained UB, we still have to compile it on the assumption that it's never dynamically executed.
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:731-739
@@ +730,11 @@
+// function zero extends the shorter of the pair so that they match.
+static void ZeroExtendToMatch(APInt &LHS, APInt &RHS) {
+ unsigned LHSBits = LHS.getBitWidth();
+ unsigned RHSBits = RHS.getBitWidth();
+
+ if (LHSBits > RHSBits)
+ RHS = RHS.zext(LHSBits);
+ else if (RHSBits > LHSBits)
+ LHS = LHS.zext(RHSBits);
+}
+
----------------
Lower-case 'z' for functions.
A simpler body would be:
unsigned Bits = std::max(LHS.getBitWidth(), RHS.getBitWidth());
LHS = LHS.zextOrSelf(Bits);
RHS = RHS.zextOrSelf(Bits);
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4484
@@ -4469,3 +4483,3 @@
SDLoc DL(N);
- if (c1 + c2 >= OpSizeInBits)
+ if ((c1 + c2).uge(OpSizeInBits))
return DAG.getConstant(0, DL, VT);
----------------
I don't think this is quite the right check, though it might not matter since it's UB anyway (e.g. c1 = c2 = 2^(Bits-1)). A comment that we made the decision intentionally might be useful though.
Repository:
rL LLVM
https://reviews.llvm.org/D23007
More information about the llvm-commits
mailing list