brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · f45cbe0 Raw
33 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; Instcombine normally would fold the sdiv into the comparison,5; making "icmp slt i32 %h, 2", but in this case the sdiv has6; another use, so it wouldn't a big win, and it would also7; obfuscate an otherise obvious smax pattern to the point where8; other analyses wouldn't recognize it.9 10define i32 @foo(i32 %h) {11; CHECK-LABEL: @foo(12; CHECK-NEXT:    [[SD:%.*]] = sdiv i32 [[H:%.*]], 213; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.smin.i32(i32 [[SD]], i32 1)14; CHECK-NEXT:    ret i32 [[R]]15;16  %sd = sdiv i32 %h, 217  %t = icmp slt i32 %sd, 118  %r = select i1 %t, i32 %sd, i32 119  ret i32 %r20}21 22define i32 @bar(i32 %h) {23; CHECK-LABEL: @bar(24; CHECK-NEXT:    [[SD:%.*]] = sdiv i32 [[H:%.*]], 225; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.smax.i32(i32 [[SD]], i32 1)26; CHECK-NEXT:    ret i32 [[R]]27;28  %sd = sdiv i32 %h, 229  %t = icmp sgt i32 %sd, 130  %r = select i1 %t, i32 %sd, i32 131  ret i32 %r32}33