| ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6 | |
| ; RUN: llc -mtriple=msp430 < %s | FileCheck %s | |
| ; A byte instruction that writes a register clears the high byte, so a zext of | |
| ; its result needs no extra instruction. | |
| define i16 @zext_add(i8 %a, i8 %b) nounwind { | |
| ; CHECK-LABEL: zext_add: | |
| ; CHECK: ; %bb.0: | |
| ; CHECK-NEXT: add.b r13, r12 | |
| ; CHECK-NEXT: ret | |
| %s = add i8 %a, %b | |
| %z = zext i8 %s to i16 | |
| ret i16 %z | |
| } | |
| ; The select is expanded into a branch and a PHI, so no byte instruction clears | |
| ; the high byte when %c is true. The zext needs a mov.b. | |
| define i16 @zext_select(i1 %c, i16 %x, i16 %y) nounwind { | |
| ; CHECK-LABEL: zext_select: | |
| ; CHECK: ; %bb.0: | |
| ; CHECK-NEXT: bit #1, r12 | |
| ; CHECK-NEXT: jne .LBB1_2 | |
| ; CHECK-NEXT: ; %bb.1: | |
| ; CHECK-NEXT: mov.b r14, r13 | |
| ; CHECK-NEXT: .LBB1_2: | |
| ; CHECK-NEXT: mov.b r13, r12 | |
| ; CHECK-NEXT: ret | |
| %a = trunc i16 %x to i8 | |
| %b = trunc i16 %y to i8 | |
| %s = select i1 %c, i8 %a, i8 %b | |
| %z = zext i8 %s to i16 | |
| ret i16 %z | |
| } | |
| ; The variable shift is expanded into a loop, so no byte instruction clears the | |
| ; high byte when %n is 0. The zext needs a mov.b. | |
| define i16 @zext_shl_var(i16 %x, i8 %n) nounwind { | |
| ; CHECK-LABEL: zext_shl_var: | |
| ; CHECK: ; %bb.0: | |
| ; CHECK-NEXT: cmp.b #0, r13 | |
| ; CHECK-NEXT: jeq .LBB2_2 | |
| ; CHECK-NEXT: .LBB2_1: ; =>This Inner Loop Header: Depth=1 | |
| ; CHECK-NEXT: add.b r12, r12 | |
| ; CHECK-NEXT: sub.b #1, r13 | |
| ; CHECK-NEXT: jne .LBB2_1 | |
| ; CHECK-NEXT: .LBB2_2: | |
| ; CHECK-NEXT: mov.b r12, r12 | |
| ; CHECK-NEXT: ret | |
| %a = trunc i16 %x to i8 | |
| %s = shl i8 %a, %n | |
| %z = zext i8 %s to i16 | |
| ret i16 %z | |
| } | |
| ; A volatile load is not combined into a zextload, but mov.b to a register | |
| ; clears the high byte, so the zext is still free. | |
| define i16 @zext_volatile_load(ptr %p) nounwind { | |
| ; CHECK-LABEL: zext_volatile_load: | |
| ; CHECK: ; %bb.0: | |
| ; CHECK-NEXT: mov.b 0(r12), r12 | |
| ; CHECK-NEXT: ret | |
| %v = load volatile i8, ptr %p | |
| %z = zext i8 %v to i16 | |
| ret i16 %z | |
| } | |
| define i16 @zext_rra(i8 %a) nounwind { | |
| ; CHECK-LABEL: zext_rra: | |
| ; CHECK: ; %bb.0: | |
| ; CHECK-NEXT: rra.b r12 | |
| ; CHECK-NEXT: ret | |
| %s = ashr i8 %a, 1 | |
| %z = zext i8 %s to i16 | |
| ret i16 %z | |
| } |