[PATCH] Make it possible for ints/floats to return different values from getBooleanContents()

hfinkel at anl.gov hfinkel at anl.gov
Tue Jul 8 13:17:36 PDT 2014

Comment at: include/llvm/Target/TargetLowering.h:960
@@ +959,3 @@
+  /// value from i1 to a wider type.  See getBooleanContents.
+  void setBooleanFloatContents(BooleanContent Ty) { BooleanFloatContents = Ty; }
I would really like to do this without causing churn to all of the targets (and causing pain for all out-of-tree targets). How about we do this:

void setBooleanContents(BooleanContent Ty) { BooleanContents = Ty; BooleanFloatContents = Ty; }

void setBooleanContents(BooleanContent Ty, BooleanContent FTy) { BooleanContents = Ty; BooleanFloatContents = FTy; }

do that the current target code will continue to do the right thing.

Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:4524
@@ -4523,1 +4523,3 @@
+  // We can't do this reliably if integer based booleans have different contents
+  // to floating point based booleans.
   if (VT.isInteger() &&
Daniel Sanders wrote:
> hfinkel at anl.gov wrote:
> > I'm missing something here... why not?
> We can't tell whether we have an integer-based boolean or a floating-point-based boolean unless we can find the SETCC that produced it and inspect its operands. This is fairly easy if C is the SETCC node, but it can potentially be undiscoverable (or not reasonably discoverable). For example, it could be in another basic block or it could require searching a complicated expression.
Okay, this is reasonable. Please make the source-code comment as informative as your reply :-)

Comment at: lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp:265
@@ +264,3 @@
+  // If integer and float booleans have different contents then we can't
+  // reliably optimize in all cases.
+  if (TLI.getBooleanContents(false, false) !=
Daniel Sanders wrote:
> hfinkel at anl.gov wrote:
> > Again, please explain.
> It's the same reason as the other one but here I attempt to cover the most likely case where Cond is a SETCC.
Please make the comment reference the comment above (in DAGCombiner::visitSELECT) for an explanation.


More information about the llvm-commits mailing list