[llvm] r285293 - [InstCombine] auto-generate better checks; NFC
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 27 06:55:38 PDT 2016
Author: spatel
Date: Thu Oct 27 08:55:37 2016
New Revision: 285293
URL: http://llvm.org/viewvc/llvm-project?rev=285293&view=rev
Log:
[InstCombine] auto-generate better checks; NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll
Modified: llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll?rev=285293&r1=285292&r2=285293&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/max-of-nots.ll Thu Oct 27 08:55:37 2016
@@ -1,23 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -instcombine < %s | FileCheck %s
define i32 @compute_min_2(i32 %x, i32 %y) {
-; CHECK-LABEL: compute_min_2
- entry:
+; CHECK-LABEL: @compute_min_2(
+; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 %x, %y
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 %x, i32 %y
+; CHECK-NEXT: ret i32 [[TMP2]]
+;
%not_x = sub i32 -1, %x
%not_y = sub i32 -1, %y
%cmp = icmp sgt i32 %not_x, %not_y
%not_min = select i1 %cmp, i32 %not_x, i32 %not_y
%min = sub i32 -1, %not_min
ret i32 %min
-
-; CHECK: %0 = icmp slt i32 %x, %y
-; CHECK-NEXT: %1 = select i1 %0, i32 %x, i32 %y
-; CHECK-NEXT: ret i32 %1
}
define i32 @compute_min_3(i32 %x, i32 %y, i32 %z) {
-; CHECK-LABEL: compute_min_3
- entry:
+; CHECK-LABEL: @compute_min_3(
+; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i32 %x, %y
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 %x, i32 %y
+; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP2]], %z
+; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i32 [[TMP2]], i32 %z
+; CHECK-NEXT: ret i32 [[TMP4]]
+;
%not_x = sub i32 -1, %x
%not_y = sub i32 -1, %y
%not_z = sub i32 -1, %z
@@ -27,41 +32,39 @@ define i32 @compute_min_3(i32 %x, i32 %y
%not_min_2 = select i1 %cmp_2, i32 %not_min_1, i32 %not_z
%min = sub i32 -1, %not_min_2
ret i32 %min
-
-; CHECK: %0 = icmp slt i32 %x, %y
-; CHECK-NEXT: %1 = select i1 %0, i32 %x, i32 %y
-; CHECK-NEXT: %2 = icmp slt i32 %1, %z
-; CHECK-NEXT: %3 = select i1 %2, i32 %1, i32 %z
-; CHECK-NEXT: ret i32 %3
}
define i32 @compute_min_arithmetic(i32 %x, i32 %y) {
-; CHECK-LABEL: compute_min_arithmetic
- entry:
+; CHECK-LABEL: @compute_min_arithmetic(
+; CHECK-NEXT: [[TMP1:%.*]] = add i32 %x, -4
+; CHECK-NEXT: [[TMP2:%.*]] = icmp slt i32 [[TMP1]], %y
+; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 [[TMP1]], i32 %y
+; CHECK-NEXT: [[TMP4:%.*]] = xor i32 [[TMP3]], -1
+; CHECK-NEXT: ret i32 [[TMP4]]
+;
%not_value = sub i32 3, %x
%not_y = sub i32 -1, %y
%cmp = icmp sgt i32 %not_value, %not_y
%not_min = select i1 %cmp, i32 %not_value, i32 %not_y
ret i32 %not_min
-
-; CHECK: %0 = add i32 %x, -4
-; CHECK-NEXT: %1 = icmp slt i32 %0, %y
-; CHECK-NEXT: %2 = select i1 %1, i32 %0, i32 %y
-; CHECK-NEXT: %3 = xor i32 %2, -1
-; CHECK-NEXT: ret i32 %3
}
declare void @fake_use(i32)
define i32 @compute_min_pessimization(i32 %x, i32 %y) {
-; CHECK-LABEL: compute_min_pessimization
- entry:
+; CHECK-LABEL: @compute_min_pessimization(
+; CHECK-NEXT: [[NOT_VALUE:%.*]] = sub i32 3, %x
+; CHECK-NEXT: call void @fake_use(i32 [[NOT_VALUE]])
+; CHECK-NEXT: [[NOT_Y:%.*]] = xor i32 %y, -1
+; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[NOT_VALUE]], [[NOT_Y]]
+; CHECK-NEXT: [[NOT_MIN:%.*]] = select i1 [[CMP]], i32 [[NOT_VALUE]], i32 [[NOT_Y]]
+; CHECK-NEXT: [[MIN:%.*]] = xor i32 [[NOT_MIN]], -1
+; CHECK-NEXT: ret i32 [[MIN]]
+;
%not_value = sub i32 3, %x
call void @fake_use(i32 %not_value)
%not_y = sub i32 -1, %y
%cmp = icmp sgt i32 %not_value, %not_y
-; CHECK: %not_value = sub i32 3, %x
-; CHECK: %cmp = icmp sgt i32 %not_value, %not_y
%not_min = select i1 %cmp, i32 %not_value, i32 %not_y
%min = sub i32 -1, %not_min
ret i32 %min
@@ -69,12 +72,13 @@ define i32 @compute_min_pessimization(i3
define i32 @max_of_nots(i32 %x, i32 %y) {
; CHECK-LABEL: @max_of_nots(
-; CHECK-NEXT: icmp
-; CHECK-NEXT: select
-; CHECK-NEXT: icmp
-; CHECK-NEXT: select
-; CHECK-NEXT: xor
-; CHECK-NEXT: ret
+; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 %y, 0
+; CHECK-NEXT: [[TMP2:%.*]] = select i1 [[TMP1]], i32 %y, i32 0
+; CHECK-NEXT: [[TMP3:%.*]] = icmp slt i32 [[TMP2]], %x
+; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i32 [[TMP2]], i32 %x
+; CHECK-NEXT: [[TMP5:%.*]] = xor i32 [[TMP4]], -1
+; CHECK-NEXT: ret i32 [[TMP5]]
+;
%c0 = icmp sgt i32 %y, 0
%xor_y = xor i32 %y, -1
%s0 = select i1 %c0, i32 %xor_y, i32 -1
@@ -83,3 +87,4 @@ define i32 @max_of_nots(i32 %x, i32 %y)
%smax96 = select i1 %c1, i32 %xor_x, i32 %s0
ret i32 %smax96
}
+
More information about the llvm-commits
mailing list