# Changeset View

Changeset View

# Standalone View

Standalone View

# llvm/trunk/test/Transforms/InstCombine/div.ll

Show First 20 Lines • Show All 526 Lines • ▼ Show 20 Line(s) | |||||

527 | ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[CONV]], 128 | 527 | ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[CONV]], 128 | ||

528 | ; CHECK-NEXT: ret i32 [[DIV]] | 528 | ; CHECK-NEXT: ret i32 [[DIV]] | ||

529 | ; | 529 | ; | ||

530 | %conv = sext i8 %x to i32 | 530 | %conv = sext i8 %x to i32 | ||

531 | %div = sdiv i32 %conv, 128 | 531 | %div = sdiv i32 %conv, 128 | ||

532 | ret i32 %div | 532 | ret i32 %div | ||

533 | } | 533 | } | ||

534 | 534 | | |||

535 | ; When the divisor is known larger than the quotient, | ||||

536 | ; InstSimplify should kill it before InstCombine sees it. | ||||

537 | | ||||

535 | define i32 @shrink_no2(i8 %x) { | 538 | define i32 @shrink_no2(i8 %x) { | ||

536 | ; CHECK-LABEL: @shrink_no2( | 539 | ; CHECK-LABEL: @shrink_no2( | ||

537 | ; CHECK-NEXT: [[CONV:%.*]] = sext i8 %x to i32 | 540 | ; CHECK-NEXT: ret i32 0 | ||

538 | ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[CONV]], -129 | | |||

539 | ; CHECK-NEXT: ret i32 [[DIV]] | | |||

540 | ; | 541 | ; | ||

541 | %conv = sext i8 %x to i32 | 542 | %conv = sext i8 %x to i32 | ||

542 | %div = sdiv i32 %conv, -129 | 543 | %div = sdiv i32 %conv, -129 | ||

543 | ret i32 %div | 544 | ret i32 %div | ||

544 | } | 545 | } | ||

545 | 546 | | |||

546 | ; 17 bits are needed to represent 65535 as a signed value, so this shouldn't fold. | | |||

547 | | ||||

548 | define i32 @shrink_no3(i16 %x) { | 547 | define i32 @shrink_no3(i16 %x) { | ||

549 | ; CHECK-LABEL: @shrink_no3( | 548 | ; CHECK-LABEL: @shrink_no3( | ||

550 | ; CHECK-NEXT: [[CONV:%.*]] = sext i16 %x to i32 | 549 | ; CHECK-NEXT: ret i32 0 | ||

551 | ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 [[CONV]], 65535 | | |||

552 | ; CHECK-NEXT: ret i32 [[DIV]] | | |||

553 | ; | 550 | ; | ||

554 | %conv = sext i16 %x to i32 | 551 | %conv = sext i16 %x to i32 | ||

555 | %div = sdiv i32 %conv, 65535 | 552 | %div = sdiv i32 %conv, 65535 | ||

556 | ret i32 %div | 553 | ret i32 %div | ||

557 | } | 554 | } | ||

558 | 555 | |