[llvm] r212515 - [SDAG] Actually check for a non-constant splat and clarify comments

Chandler Carruth chandlerc at gmail.com
Tue Jul 8 00:44:15 PDT 2014


Author: chandlerc
Date: Tue Jul  8 02:44:15 2014
New Revision: 212515

URL: http://llvm.org/viewvc/llvm-project?rev=212515&view=rev
Log:
[SDAG] Actually check for a non-constant splat and clarify comments
around the handling of UNDEF lanes in boolean vector content analysis.

The code before my changes here also failed to check for non-constant
splats in a buildvector. I have no idea how to trigger this, I just
spotted by inspection when trying to understand the code. It seems
extremely unlikely to be worth the trouble to teach the only caller of
this code (DAG combining setcc patterns) how to cleverly handle undef
lanes, so I've just commented more thoroughly that we're giving up
there.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp?rev=212515&r1=212514&r2=212515&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/TargetLowering.cpp Tue Jul  8 02:44:15 2014
@@ -1160,8 +1160,10 @@ bool TargetLowering::isConstTrueVal(cons
     IsVec = true;
     bool HasUndefElements;
     CN = BV->getConstantSplatNode(HasUndefElements);
-    if (HasUndefElements)
-      return false; // Can't blindly collapse the undef values.
+    // Only interested in constant splats, and we don't try to handle undef
+    // elements in identifying boolean constants.
+    if (!CN || HasUndefElements)
+      return false;
   }
 
   switch (getBooleanContents(IsVec)) {
@@ -1190,8 +1192,10 @@ bool TargetLowering::isConstFalseVal(con
     IsVec = true;
     bool HasUndefElements;
     CN = BV->getConstantSplatNode(HasUndefElements);
-    if (HasUndefElements)
-      return false; // Can't blindly collapse the undef values.
+    // Only interested in constant splats, and we don't try to handle undef
+    // elements in identifying boolean constants.
+    if (!CN || HasUndefElements)
+      return false;
   }
 
   if (getBooleanContents(IsVec) == UndefinedBooleanContent)





More information about the llvm-commits mailing list