[PATCH] SelectionDAG: mimic InstCombine when comparing to undef
Mehdi AMINI
mehdi.amini at apple.com
Thu Feb 12 19:20:07 PST 2015
Hi hfinkel,
This implements the same folding for SelectionDAG than what is present in InstCombine.
I haven't put a test yet, and it breaks the validation, but before fixing this I seek opinion on NaN handling here. InstCombine does not care and I don't really see why the same IR would be handled differently in the DAG than in InstCombine.
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7602
Files:
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Index: lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1912,6 +1912,18 @@
}
}
+ // InstCombine implements:
+ //
+ // icmp X, X -> true/false
+ // X icmp undef -> true/false. For example, icmp ugt %X, undef -> false
+ // because X could be 0.
+ //
+ // fcmp pred X, undef -> undef
+ //
+ // Do the same here
+ if (N1 == N2 || N1.getOpcode() == ISD::UNDEF || N1.getOpcode() == ISD::UNDEF)
+ return getConstant(isTrueWhenEqual(Cond), VT);
+
// Could not fold it.
return SDValue();
}
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7602.19866.patch
Type: text/x-patch
Size: 669 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150213/7c5c0732/attachment.bin>
More information about the llvm-commits
mailing list