]> granicus.if.org Git - llvm/commitdiff
DAG: Follow-up to r319692 check the truncates inputs have the same type
authorHans Wennborg <hans@hanshq.net>
Mon, 4 Dec 2017 20:48:50 +0000 (20:48 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 4 Dec 2017 20:48:50 +0000 (20:48 +0000)
MatchRotate assumes the types of the types of LHS and RHS are equal,
which is always the case then they come from an OR node, but here
we're getting them from two different TRUNC nodes, so we have to check
the types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319695 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index 30195ff4e91beb11360ce2fb9b6f1620c4ca4eec..ffce8545a149c7d9fafb2caae6f7143fb831becf 100644 (file)
@@ -4653,7 +4653,8 @@ SDNode *DAGCombiner::MatchRotate(SDValue LHS, SDValue RHS, const SDLoc &DL) {
   if (!HasROTL && !HasROTR) return nullptr;
 
   // Check for truncated rotate.
-  if (LHS.getOpcode() == ISD::TRUNCATE && RHS.getOpcode() == ISD::TRUNCATE) {
+  if (LHS.getOpcode() == ISD::TRUNCATE && RHS.getOpcode() == ISD::TRUNCATE &&
+      LHS.getOperand(0).getValueType() == RHS.getOperand(0).getValueType()) {
     assert(LHS.getValueType() == RHS.getValueType());
     if (SDNode *Rot = MatchRotate(LHS.getOperand(0), RHS.getOperand(0), DL)) {
       return DAG.getNode(ISD::TRUNCATE, SDLoc(LHS), LHS.getValueType(),