[PATCH] D54359: [InstCombine] Remove a couple of asserts based on incorrect assumptions
Mandeep Singh Grang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 11 11:17:35 PST 2018
mgrang updated this revision to Diff 173567.
mgrang added a comment.
Simplified unit test.
https://reviews.llvm.org/D54359
Files:
Transforms/InstCombine/InstCombineSelect.cpp
Transforms/InstCombine/select-pr39595.ll
Index: Transforms/InstCombine/select-pr39595.ll
===================================================================
--- /dev/null
+++ Transforms/InstCombine/select-pr39595.ll
@@ -0,0 +1,18 @@
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+define i32 @foo(i32 %x, i32 %y) {
+; CHECK-LABEL: foo
+; CHECK: [[TMP1:%.*]] = icmp ult i32 %y, %x
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 %x, i32 %y, !prof ![[$MD0:[0-9]+]]
+; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP2]], -1
+; CHECK-NEXT: ret i32 [[TMP3:%.*]]
+; CHECK-DAG: !0 = !{!"branch_weights", i32 1, i32 6}
+
+ %1 = xor i32 %x, -1
+ %2 = xor i32 %y, -1
+ %3 = icmp ugt i32 %1, %2
+ %4 = select i1 %3, i32 %2, i32 %1, !prof !1
+ ret i32 %4
+}
+
+!1 = !{!"branch_weights", i32 1, i32 6}
Index: Transforms/InstCombine/InstCombineSelect.cpp
===================================================================
--- Transforms/InstCombine/InstCombineSelect.cpp
+++ Transforms/InstCombine/InstCombineSelect.cpp
@@ -1820,14 +1820,8 @@
if (MDNode *MD = SI.getMetadata(LLVMContext::MD_prof)) {
cast<SelectInst>(NewMinMax)->setMetadata(LLVMContext::MD_prof, MD);
// Swap the metadata if the operands are swapped.
- if (Swapped) {
- assert(X == SI.getFalseValue() && Y == SI.getTrueValue() &&
- "Unexpected operands.");
+ if (Swapped)
cast<SelectInst>(NewMinMax)->swapProfMetadata();
- } else {
- assert(X == SI.getTrueValue() && Y == SI.getFalseValue() &&
- "Unexpected operands.");
- }
}
return BinaryOperator::CreateNot(NewMinMax);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54359.173567.patch
Type: text/x-patch
Size: 1684 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181111/5ee5d9ef/attachment.bin>
More information about the llvm-commits
mailing list