[PATCH] D24181: IfConversion: Add assertions that both sides of a diamond don't pred-clobber.

Kyle Butt via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 1 18:38:15 PDT 2016

iteratee created this revision.
iteratee added a reviewer: davidxl.
iteratee added a subscriber: llvm-commits.
iteratee set the repository for this revision to rL LLVM.

One side of a diamond may end with a predicate clobbering instruction.
That side of the diamond has to be if-converted second. Both sides can't
clobber the predicate or the ifconversion is invalid. This is checked
elsewhere, but add an assert as a safety check. NFC




Index: lib/CodeGen/IfConversion.cpp
--- lib/CodeGen/IfConversion.cpp
+++ lib/CodeGen/IfConversion.cpp
@@ -1753,10 +1753,11 @@
   bool DoSwap = false;
   if (TClobbersPred && !FClobbersPred)
     DoSwap = true;
-  else if (TClobbersPred == FClobbersPred) {
+  else if (!TClobbersPred && !FClobbersPred) {
     if (TrueBBI.NonPredSize > FalseBBI.NonPredSize)
       DoSwap = true;
-  }
+  } else if (TClobbersPred && FClobbersPred)
+    llvm_unreachable("Predicate info cannot be clobbered by both sides.");
   if (DoSwap) {
     std::swap(BBI1, BBI2);
     std::swap(Cond1, Cond2);

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24181.70126.patch
Type: text/x-patch
Size: 649 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160902/37c37881/attachment.bin>

More information about the llvm-commits mailing list