[PATCH] Fix DAG fold that didn't check legal ops

escha escha at apple.com
Sun May 17 19:51:43 PDT 2015


This should be straightforward: an out-of-tree target has legal ZERO_EXTEND for a type which is not legal for AND, which causes breakage.

—escha

Index: lib/CodeGen/SelectionDAG/DAGCombiner.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/DAGCombiner.cpp	(revision 237549)
+++ lib/CodeGen/SelectionDAG/DAGCombiner.cpp	(working copy)
@@ -6100,6 +6100,7 @@
   // Fold (zext (and (trunc x), cst)) -> (and x, cst),
   // if either of the casts is not free.
   if (N0.getOpcode() == ISD::AND &&
+      (!LegalOperations || TLI.isOperationLegal(ISD::AND, VT)) &&
       N0.getOperand(0).getOpcode() == ISD::TRUNCATE &&
       N0.getOperand(1).getOpcode() == ISD::Constant &&
       (!TLI.isTruncateFree(N0.getOperand(0).getOperand(0).getValueType(),
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150517/389bbc1f/attachment.html>


More information about the llvm-commits mailing list