@@ -371,16 +371,14 @@ func.func @if_for() {
371371// CHECK-NEXT: %[[c1:.*]] = arith.constant 1 : index
372372// CHECK-NEXT: for %{{.*}} = %[[c0]] to %[[c42]] step %[[c1]] {
373373// CHECK-NEXT: %[[cm1:.*]] = arith.constant -1 : index
374- // CHECK-NEXT: %[[a:.*]] = arith.muli %{{.*}}, %[[cm1]] : index
375- // CHECK-NEXT: %[[b:.*]] = arith.addi %[[a]], %{{.*}} : index
376- // CHECK-NEXT: %[[c:.*]] = arith.cmpi sgt, %{{.*}}, %[[b]] : index
377- // CHECK-NEXT: %[[d:.*]] = arith.select %[[c]], %{{.*}}, %[[b]] : index
374+ // CHECK-NEXT: %[[mul0:.*]] = arith.muli %{{.*}}, %[[cm1]] : index
375+ // CHECK-NEXT: %[[add0:.*]] = arith.addi %[[mul0]], %{{.*}} : index
376+ // CHECK-NEXT: %[[max:.*]] = arith.maxsi %{{.*}}, %[[add0]] : index
378377// CHECK-NEXT: %[[c10:.*]] = arith.constant 10 : index
379- // CHECK-NEXT: %[[e:.*]] = arith.addi %{{.*}}, %[[c10]] : index
380- // CHECK-NEXT: %[[f:.*]] = arith.cmpi slt, %{{.*}}, %[[e]] : index
381- // CHECK-NEXT: %[[g:.*]] = arith.select %[[f]], %{{.*}}, %[[e]] : index
378+ // CHECK-NEXT: %[[add1:.*]] = arith.addi %{{.*}}, %[[c10]] : index
379+ // CHECK-NEXT: %[[min:.*]] = arith.minsi %{{.*}}, %[[add1]] : index
382380// CHECK-NEXT: %[[c1_0:.*]] = arith.constant 1 : index
383- // CHECK-NEXT: for %{{.*}} = %[[d ]] to %[[g ]] step %[[c1_0]] {
381+ // CHECK-NEXT: for %{{.*}} = %[[max ]] to %[[min ]] step %[[c1_0]] {
384382// CHECK-NEXT: call @body2(%{{.*}}, %{{.*}}) : (index, index) -> ()
385383// CHECK-NEXT: }
386384// CHECK-NEXT: }
@@ -397,25 +395,19 @@ func.func @loop_min_max(%N : index) {
397395
398396#map_7_values = affine_map <(d0 , d1 , d2 , d3 , d4 , d5 , d6 ) -> (d0 , d1 , d2 , d3 , d4 , d5 , d6 )>
399397
400- // Check that the "min" (cmpi slt + select) reduction sequence is emitted
398+ // Check that the "min" reduction sequence is emitted
401399// correctly for an affine map with 7 results.
402400
403401// CHECK-LABEL: func @min_reduction_tree
404402// CHECK-NEXT: %[[c0:.*]] = arith.constant 0 : index
405- // CHECK-NEXT: %[[c01:.+]] = arith.cmpi slt, %{{.*}}, %{{.*}} : index
406- // CHECK-NEXT: %[[r01:.+]] = arith.select %[[c01]], %{{.*}}, %{{.*}} : index
407- // CHECK-NEXT: %[[c012:.+]] = arith.cmpi slt, %[[r01]], %{{.*}} : index
408- // CHECK-NEXT: %[[r012:.+]] = arith.select %[[c012]], %[[r01]], %{{.*}} : index
409- // CHECK-NEXT: %[[c0123:.+]] = arith.cmpi slt, %[[r012]], %{{.*}} : index
410- // CHECK-NEXT: %[[r0123:.+]] = arith.select %[[c0123]], %[[r012]], %{{.*}} : index
411- // CHECK-NEXT: %[[c01234:.+]] = arith.cmpi slt, %[[r0123]], %{{.*}} : index
412- // CHECK-NEXT: %[[r01234:.+]] = arith.select %[[c01234]], %[[r0123]], %{{.*}} : index
413- // CHECK-NEXT: %[[c012345:.+]] = arith.cmpi slt, %[[r01234]], %{{.*}} : index
414- // CHECK-NEXT: %[[r012345:.+]] = arith.select %[[c012345]], %[[r01234]], %{{.*}} : index
415- // CHECK-NEXT: %[[c0123456:.+]] = arith.cmpi slt, %[[r012345]], %{{.*}} : index
416- // CHECK-NEXT: %[[r0123456:.+]] = arith.select %[[c0123456]], %[[r012345]], %{{.*}} : index
403+ // CHECK-NEXT: %[[min:.+]] = arith.minsi %{{.*}}, %{{.*}} : index
404+ // CHECK-NEXT: %[[min_0:.+]] = arith.minsi %[[min]], %{{.*}} : index
405+ // CHECK-NEXT: %[[min_1:.+]] = arith.minsi %[[min_0]], %{{.*}} : index
406+ // CHECK-NEXT: %[[min_2:.+]] = arith.minsi %[[min_1]], %{{.*}} : index
407+ // CHECK-NEXT: %[[min_3:.+]] = arith.minsi %[[min_2]], %{{.*}} : index
408+ // CHECK-NEXT: %[[min_4:.+]] = arith.minsi %[[min_3]], %{{.*}} : index
417409// CHECK-NEXT: %[[c1:.*]] = arith.constant 1 : index
418- // CHECK-NEXT: for %{{.*}} = %[[c0]] to %[[r0123456 ]] step %[[c1]] {
410+ // CHECK-NEXT: for %{{.*}} = %[[c0]] to %[[min_4 ]] step %[[c1]] {
419411// CHECK-NEXT: call @body(%{{.*}}) : (index) -> ()
420412// CHECK-NEXT: }
421413// CHECK-NEXT: return
@@ -690,8 +682,7 @@ func.func @affine_min(%arg0: index, %arg1: index) -> index{
690682 // CHECK: %[[Cm2:.*]] = arith.constant -1
691683 // CHECK: %[[neg2:.*]] = arith.muli %[[ARG0]], %[[Cm2:.*]]
692684 // CHECK: %[[second:.*]] = arith.addi %[[ARG1]], %[[neg2]]
693- // CHECK: %[[cmp:.*]] = arith.cmpi slt, %[[first]], %[[second]]
694- // CHECK: arith.select %[[cmp]], %[[first]], %[[second]]
685+ // CHECK: arith.minsi %[[first]], %[[second]]
695686 %0 = affine.min affine_map <(d0 ,d1 ) -> (d0 - d1 , d1 - d0 )>(%arg0 , %arg1 )
696687 return %0 : index
697688}
@@ -705,8 +696,7 @@ func.func @affine_max(%arg0: index, %arg1: index) -> index{
705696 // CHECK: %[[Cm2:.*]] = arith.constant -1
706697 // CHECK: %[[neg2:.*]] = arith.muli %[[ARG0]], %[[Cm2:.*]]
707698 // CHECK: %[[second:.*]] = arith.addi %[[ARG1]], %[[neg2]]
708- // CHECK: %[[cmp:.*]] = arith.cmpi sgt, %[[first]], %[[second]]
709- // CHECK: arith.select %[[cmp]], %[[first]], %[[second]]
699+ // CHECK: arith.maxsi %[[first]], %[[second]]
710700 %0 = affine.max affine_map <(d0 ,d1 ) -> (d0 - d1 , d1 - d0 )>(%arg0 , %arg1 )
711701 return %0 : index
712702}
0 commit comments