419 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4; For the following patterns:5; umax(nuw_shl(z, x), nuw_shl(z, y)) -> nuw_shl(z, umax(x, y))6; umin(nuw_shl(z, x), nuw_shl(z, y)) -> nuw_shl(z, umin(x, y))7; umax(nuw_shl(x, z), nuw_shl(y, z)) -> nuw_shl(umax(x, y), z)8; umin(nuw_shl(x, z), nuw_shl(y, z)) -> nuw_shl(umin(x, y), z)9 10define i32 @umax_shl_common_lhs(i32 %x, i32 %y, i32 %z) {11; CHECK-LABEL: define i32 @umax_shl_common_lhs(12; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {13; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]])14; CHECK-NEXT: [[MAX:%.*]] = shl nuw i32 [[Z]], [[TMP1]]15; CHECK-NEXT: ret i32 [[MAX]]16;17 %shl_x = shl nuw i32 %z, %x18 %shl_y = shl nuw i32 %z, %y19 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)20 ret i32 %max21}22 23define i32 @umax_shl_common_rhs(i32 %x, i32 %y, i32 %z) {24; CHECK-LABEL: define i32 @umax_shl_common_rhs(25; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {26; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]])27; CHECK-NEXT: [[MAX:%.*]] = shl nuw i32 [[TMP1]], [[Z]]28; CHECK-NEXT: ret i32 [[MAX]]29;30 %shl_x = shl nuw i32 %x, %z31 %shl_y = shl nuw i32 %y, %z32 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)33 ret i32 %max34}35 36define i32 @umin_shl_common_lhs(i32 %x, i32 %y, i32 %z) {37; CHECK-LABEL: define i32 @umin_shl_common_lhs(38; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {39; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 [[Y]])40; CHECK-NEXT: [[MIN:%.*]] = shl nuw i32 [[Z]], [[TMP1]]41; CHECK-NEXT: ret i32 [[MIN]]42;43 %shl_x = shl nuw i32 %z, %x44 %shl_y = shl nuw i32 %z, %y45 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)46 ret i32 %min47}48 49define i32 @umin_shl_common_rhs(i32 %x, i32 %y, i32 %z) {50; CHECK-LABEL: define i32 @umin_shl_common_rhs(51; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {52; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 [[Y]])53; CHECK-NEXT: [[MIN:%.*]] = shl nuw i32 [[TMP1]], [[Z]]54; CHECK-NEXT: ret i32 [[MIN]]55;56 %shl_x = shl nuw i32 %x, %z57 %shl_y = shl nuw i32 %y, %z58 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)59 ret i32 %min60}61 62define i32 @umax_shl_common_lhs_const1(i32 %x, i32 %y) {63; CHECK-LABEL: define i32 @umax_shl_common_lhs_const1(64; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {65; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]])66; CHECK-NEXT: [[MAX:%.*]] = shl nuw i32 1, [[TMP1]]67; CHECK-NEXT: ret i32 [[MAX]]68;69 %shl_x = shl nuw i32 1, %x70 %shl_y = shl nuw i32 1, %y71 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)72 ret i32 %max73}74 75define i32 @umax_shl_common_rhs_const1(i32 %x, i32 %y) {76; CHECK-LABEL: define i32 @umax_shl_common_rhs_const1(77; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {78; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]])79; CHECK-NEXT: [[MAX:%.*]] = shl nuw i32 [[TMP1]], 180; CHECK-NEXT: ret i32 [[MAX]]81;82 %shl_x = shl nuw i32 %x, 183 %shl_y = shl nuw i32 %y, 184 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)85 ret i32 %max86}87 88define i32 @umin_shl_common_lhs_const1(i32 %x, i32 %y) {89; CHECK-LABEL: define i32 @umin_shl_common_lhs_const1(90; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {91; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 [[Y]])92; CHECK-NEXT: [[MIN:%.*]] = shl nuw i32 1, [[TMP1]]93; CHECK-NEXT: ret i32 [[MIN]]94;95 %shl_x = shl nuw i32 1, %x96 %shl_y = shl nuw i32 1, %y97 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)98 ret i32 %min99}100 101define i32 @umin_shl_common_rhs_const1(i32 %x, i32 %y) {102; CHECK-LABEL: define i32 @umin_shl_common_rhs_const1(103; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {104; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[X]], i32 [[Y]])105; CHECK-NEXT: [[MIN:%.*]] = shl nuw i32 [[TMP1]], 1106; CHECK-NEXT: ret i32 [[MIN]]107;108 %shl_x = shl nuw i32 %x, 1109 %shl_y = shl nuw i32 %y, 1110 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)111 ret i32 %min112}113 114declare void @use(i8)115 116define i32 @umax_shl_common_lhs_multi_use(i32 %x, i32 %y, i32 %z) {117; CHECK-LABEL: define i32 @umax_shl_common_lhs_multi_use(118; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {119; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[Z]], [[X]]120; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Z]], [[Y]]121; CHECK-NEXT: call void @use(i32 [[SHL_X]])122; CHECK-NEXT: call void @use(i32 [[SHL_Y]])123; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])124; CHECK-NEXT: ret i32 [[MAX]]125;126 %shl_x = shl nuw i32 %z, %x127 %shl_y = shl nuw i32 %z, %y128 call void @use(i32 %shl_x)129 call void @use(i32 %shl_y)130 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)131 ret i32 %max132}133 134define i32 @umax_shl_common_rhs_multi_use(i32 %x, i32 %y, i32 %z) {135; CHECK-LABEL: define i32 @umax_shl_common_rhs_multi_use(136; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {137; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], [[Z]]138; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Y]], [[Z]]139; CHECK-NEXT: call void @use(i32 [[SHL_X]])140; CHECK-NEXT: call void @use(i32 [[SHL_Y]])141; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])142; CHECK-NEXT: ret i32 [[MAX]]143;144 %shl_x = shl nuw i32 %x, %z145 %shl_y = shl nuw i32 %y, %z146 call void @use(i32 %shl_x)147 call void @use(i32 %shl_y)148 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)149 ret i32 %max150}151 152define i32 @umin_shl_common_lhs_multi_use(i32 %x, i32 %y, i32 %z) {153; CHECK-LABEL: define i32 @umin_shl_common_lhs_multi_use(154; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {155; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[Z]], [[X]]156; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Z]], [[Y]]157; CHECK-NEXT: call void @use(i32 [[SHL_X]])158; CHECK-NEXT: call void @use(i32 [[SHL_Y]])159; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL_X]], i32 [[SHL_Y]])160; CHECK-NEXT: ret i32 [[MIN]]161;162 %shl_x = shl nuw i32 %z, %x163 %shl_y = shl nuw i32 %z, %y164 call void @use(i32 %shl_x)165 call void @use(i32 %shl_y)166 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)167 ret i32 %min168}169 170define i32 @umin_shl_common_rhs_multi_use(i32 %x, i32 %y, i32 %z) {171; CHECK-LABEL: define i32 @umin_shl_common_rhs_multi_use(172; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {173; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], [[Z]]174; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Y]], [[Z]]175; CHECK-NEXT: call void @use(i32 [[SHL_X]])176; CHECK-NEXT: call void @use(i32 [[SHL_Y]])177; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL_X]], i32 [[SHL_Y]])178; CHECK-NEXT: ret i32 [[MIN]]179;180 %shl_x = shl nuw i32 %x, %z181 %shl_y = shl nuw i32 %y, %z182 call void @use(i32 %shl_x)183 call void @use(i32 %shl_y)184 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)185 ret i32 %min186}187 188define i32 @umax_shl_common_lhs_commuted(i32 %x, i32 %y, i32 %z) {189; CHECK-LABEL: define i32 @umax_shl_common_lhs_commuted(190; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {191; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[Y]], i32 [[X]])192; CHECK-NEXT: [[MAX:%.*]] = shl nuw i32 [[Z]], [[TMP1]]193; CHECK-NEXT: ret i32 [[MAX]]194;195 %shl_x = shl nuw i32 %z, %x196 %shl_y = shl nuw i32 %z, %y197 %max = call i32 @llvm.umax.i32(i32 %shl_y, i32 %shl_x)198 ret i32 %max199}200 201define i32 @umax_shl_common_rhs_commuted(i32 %x, i32 %y, i32 %z) {202; CHECK-LABEL: define i32 @umax_shl_common_rhs_commuted(203; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {204; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[Y]], i32 [[X]])205; CHECK-NEXT: [[MAX:%.*]] = shl nuw i32 [[TMP1]], [[Z]]206; CHECK-NEXT: ret i32 [[MAX]]207;208 %shl_x = shl nuw i32 %x, %z209 %shl_y = shl nuw i32 %y, %z210 %max = call i32 @llvm.umax.i32(i32 %shl_y, i32 %shl_x)211 ret i32 %max212}213 214define i32 @umin_shl_common_lhs_commuted(i32 %x, i32 %y, i32 %z) {215; CHECK-LABEL: define i32 @umin_shl_common_lhs_commuted(216; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {217; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[Y]], i32 [[X]])218; CHECK-NEXT: [[MIN:%.*]] = shl nuw i32 [[Z]], [[TMP1]]219; CHECK-NEXT: ret i32 [[MIN]]220;221 %shl_x = shl nuw i32 %z, %x222 %shl_y = shl nuw i32 %z, %y223 %min = call i32 @llvm.umin.i32(i32 %shl_y, i32 %shl_x)224 ret i32 %min225}226 227define i32 @umin_shl_common_rhs_commuted(i32 %x, i32 %y, i32 %z) {228; CHECK-LABEL: define i32 @umin_shl_common_rhs_commuted(229; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {230; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umin.i32(i32 [[Y]], i32 [[X]])231; CHECK-NEXT: [[MIN:%.*]] = shl nuw i32 [[TMP1]], [[Z]]232; CHECK-NEXT: ret i32 [[MIN]]233;234 %shl_x = shl nuw i32 %x, %z235 %shl_y = shl nuw i32 %y, %z236 %min = call i32 @llvm.umin.i32(i32 %shl_y, i32 %shl_x)237 ret i32 %min238}239 240define <2 x i32> @umax_shl_common_lhs_vector(<2 x i32> %z, <2 x i32> %x, <2 x i32> %y) {241; CHECK-LABEL: define <2 x i32> @umax_shl_common_lhs_vector(242; CHECK-SAME: <2 x i32> [[Z:%.*]], <2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]]) {243; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.umax.v2i32(<2 x i32> [[X]], <2 x i32> [[Y]])244; CHECK-NEXT: [[MAX:%.*]] = shl nuw <2 x i32> [[Z]], [[TMP1]]245; CHECK-NEXT: ret <2 x i32> [[MAX]]246;247 %shl_x = shl nuw <2 x i32> %z, %x248 %shl_y = shl nuw <2 x i32> %z, %y249 %max = call <2 x i32> @llvm.umax.v2i32(<2 x i32> %shl_x, <2 x i32> %shl_y)250 ret <2 x i32> %max251}252 253define <2 x i32> @umax_shl_common_rhs_vector(<2 x i32> %z, <2 x i32> %x, <2 x i32> %y) {254; CHECK-LABEL: define <2 x i32> @umax_shl_common_rhs_vector(255; CHECK-SAME: <2 x i32> [[Z:%.*]], <2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]]) {256; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.umax.v2i32(<2 x i32> [[X]], <2 x i32> [[Y]])257; CHECK-NEXT: [[MAX:%.*]] = shl nuw <2 x i32> [[TMP1]], [[Z]]258; CHECK-NEXT: ret <2 x i32> [[MAX]]259;260 %shl_x = shl nuw <2 x i32> %x, %z261 %shl_y = shl nuw <2 x i32> %y, %z262 %max = call <2 x i32> @llvm.umax.v2i32(<2 x i32> %shl_x, <2 x i32> %shl_y)263 ret <2 x i32> %max264}265 266 267define <2 x i32> @umin_shl_common_lhs_vector(<2 x i32> %z, <2 x i32> %x, <2 x i32> %y) {268; CHECK-LABEL: define <2 x i32> @umin_shl_common_lhs_vector(269; CHECK-SAME: <2 x i32> [[Z:%.*]], <2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]]) {270; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.umin.v2i32(<2 x i32> [[X]], <2 x i32> [[Y]])271; CHECK-NEXT: [[MIN:%.*]] = shl nuw <2 x i32> [[Z]], [[TMP1]]272; CHECK-NEXT: ret <2 x i32> [[MIN]]273;274 %shl_x = shl nuw <2 x i32> %z, %x275 %shl_y = shl nuw <2 x i32> %z, %y276 %min = call <2 x i32> @llvm.umin.v2i32(<2 x i32> %shl_x, <2 x i32> %shl_y)277 ret <2 x i32> %min278}279 280define <2 x i32> @umin_shl_common_rhs_vector(<2 x i32> %z, <2 x i32> %x, <2 x i32> %y) {281; CHECK-LABEL: define <2 x i32> @umin_shl_common_rhs_vector(282; CHECK-SAME: <2 x i32> [[Z:%.*]], <2 x i32> [[X:%.*]], <2 x i32> [[Y:%.*]]) {283; CHECK-NEXT: [[TMP1:%.*]] = call <2 x i32> @llvm.umin.v2i32(<2 x i32> [[X]], <2 x i32> [[Y]])284; CHECK-NEXT: [[MIN:%.*]] = shl nuw <2 x i32> [[TMP1]], [[Z]]285; CHECK-NEXT: ret <2 x i32> [[MIN]]286;287 %shl_x = shl nuw <2 x i32> %x, %z288 %shl_y = shl nuw <2 x i32> %y, %z289 %min = call <2 x i32> @llvm.umin.v2i32(<2 x i32> %shl_x, <2 x i32> %shl_y)290 ret <2 x i32> %min291}292 293; Negative tests294 295define i32 @umax_shl_different_lhs(i32 %z1, i32 %z2, i32 %x, i32 %y) {296; CHECK-LABEL: define i32 @umax_shl_different_lhs(297; CHECK-SAME: i32 [[Z1:%.*]], i32 [[Z2:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]]) {298; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[Z1]], [[X]]299; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Z2]], [[Y]]300; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])301; CHECK-NEXT: ret i32 [[MAX]]302;303 %shl_x = shl nuw i32 %z1, %x304 %shl_y = shl nuw i32 %z2, %y305 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)306 ret i32 %max307}308 309define i32 @umax_shl_different_rhs(i32 %z1, i32 %z2, i32 %x, i32 %y) {310; CHECK-LABEL: define i32 @umax_shl_different_rhs(311; CHECK-SAME: i32 [[Z1:%.*]], i32 [[Z2:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]]) {312; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], [[Z1]]313; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Y]], [[Z2]]314; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])315; CHECK-NEXT: ret i32 [[MAX]]316;317 %shl_x = shl nuw i32 %x, %z1318 %shl_y = shl nuw i32 %y, %z2319 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)320 ret i32 %max321}322 323define i32 @umin_shl_different_lhs(i32 %z1, i32 %z2, i32 %x, i32 %y) {324; CHECK-LABEL: define i32 @umin_shl_different_lhs(325; CHECK-SAME: i32 [[Z1:%.*]], i32 [[Z2:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]]) {326; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[Z1]], [[X]]327; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Z2]], [[Y]]328; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL_X]], i32 [[SHL_Y]])329; CHECK-NEXT: ret i32 [[MIN]]330;331 %shl_x = shl nuw i32 %z1, %x332 %shl_y = shl nuw i32 %z2, %y333 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)334 ret i32 %min335}336 337define i32 @umin_shl_different_rhs(i32 %z1, i32 %z2, i32 %x, i32 %y) {338; CHECK-LABEL: define i32 @umin_shl_different_rhs(339; CHECK-SAME: i32 [[Z1:%.*]], i32 [[Z2:%.*]], i32 [[X:%.*]], i32 [[Y:%.*]]) {340; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], [[Z1]]341; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Y]], [[Z2]]342; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL_X]], i32 [[SHL_Y]])343; CHECK-NEXT: ret i32 [[MIN]]344;345 %shl_x = shl nuw i32 %x, %z1346 %shl_y = shl nuw i32 %y, %z2347 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)348 ret i32 %min349}350 351define i32 @umax_shl_does_not_commute(i32 %x, i32 %y, i32 %z) {352; CHECK-LABEL: define i32 @umax_shl_does_not_commute(353; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {354; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], [[Y]]355; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Y]], [[Z]]356; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])357; CHECK-NEXT: ret i32 [[MAX]]358;359 %shl_x = shl nuw i32 %x, %y360 %shl_y = shl nuw i32 %y, %z361 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)362 ret i32 %max363}364 365define i32 @umin_shl_does_not_commute(i32 %x, i32 %y, i32 %z) {366; CHECK-LABEL: define i32 @umin_shl_does_not_commute(367; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {368; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], [[Y]]369; CHECK-NEXT: [[SHL_Y:%.*]] = shl nuw i32 [[Y]], [[Z]]370; CHECK-NEXT: [[MIN:%.*]] = call i32 @llvm.umin.i32(i32 [[SHL_X]], i32 [[SHL_Y]])371; CHECK-NEXT: ret i32 [[MIN]]372;373 %shl_x = shl nuw i32 %x, %y374 %shl_y = shl nuw i32 %y, %z375 %min = call i32 @llvm.umin.i32(i32 %shl_x, i32 %shl_y)376 ret i32 %min377}378 379define i32 @umax_shl_common_lhs_no_nuw_flag(i32 %x, i32 %y) {380; CHECK-LABEL: define i32 @umax_shl_common_lhs_no_nuw_flag(381; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {382; CHECK-NEXT: [[SHL_X:%.*]] = shl i32 2, [[X]]383; CHECK-NEXT: [[SHL_Y:%.*]] = shl i32 2, [[Y]]384; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])385; CHECK-NEXT: ret i32 [[MAX]]386;387 %shl_x = shl i32 2, %x388 %shl_y = shl i32 2, %y389 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)390 ret i32 %max391}392 393define i32 @umax_shl_common_rhs_no_nuw_flag(i32 %x, i32 %y) {394; CHECK-LABEL: define i32 @umax_shl_common_rhs_no_nuw_flag(395; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]]) {396; CHECK-NEXT: [[SHL_X:%.*]] = shl nuw i32 [[X]], 2397; CHECK-NEXT: [[SHL_Y:%.*]] = shl i32 [[Y]], 2398; CHECK-NEXT: [[MAX:%.*]] = call i32 @llvm.umax.i32(i32 [[SHL_X]], i32 [[SHL_Y]])399; CHECK-NEXT: ret i32 [[MAX]]400;401 %shl_x = shl nuw i32 %x, 2402 %shl_y = shl i32 %y, 2403 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)404 ret i32 %max405}406 407define i32 @umax_shl_common_lhs_preserve_nsw(i32 %x, i32 %y, i32 %z) {408; CHECK-LABEL: define i32 @umax_shl_common_lhs_preserve_nsw(409; CHECK-SAME: i32 [[X:%.*]], i32 [[Y:%.*]], i32 [[Z:%.*]]) {410; CHECK-NEXT: [[TMP1:%.*]] = call i32 @llvm.umax.i32(i32 [[X]], i32 [[Y]])411; CHECK-NEXT: [[MAX:%.*]] = shl nuw nsw i32 [[Z]], [[TMP1]]412; CHECK-NEXT: ret i32 [[MAX]]413;414 %shl_x = shl nuw nsw i32 %z, %x415 %shl_y = shl nuw nsw i32 %z, %y416 %max = call i32 @llvm.umax.i32(i32 %shl_x, i32 %shl_y)417 ret i32 %max418}419