154 lines · plain
1# RUN: llc -mtriple=x86_64-unknown-linux-gnu -run-pass x86-fixup-bw-insts %s -o - | FileCheck %s2 3--- |4 define void @test1() { ret void }5 define void @test2() { ret void }6 7 define i16 @test3(ptr readonly %p) {8 ; Keep original IR to show how the situation like this might happen9 ; due to preceding CG passes.10 ;11 ; %0 is used in %if.end BB (before tail-duplication), so its12 ; corresponding super-register (EAX) is live-in into that BB (%if.end)13 ; and also has an implicit-def EAX flag. Make sure that we still change14 ; the movw into movzwl because EAX is not live before the load (which15 ; can be seen by the fact that implicit EAX flag is missing).16 entry:17 %tobool = icmp eq ptr %p, null18 br i1 %tobool, label %if.end, label %if.then19 20 if.then: ; preds = %entry21 %0 = load i16, ptr %p, align 222 br label %if.end23 24 if.end: ; preds = %if.then, %entry25 %i.0 = phi i16 [ %0, %if.then ], [ 0, %entry ]26 ret i16 %i.027 }28 29 define i16 @test4() {30 entry:31 %t1 = zext i1 undef to i1632 %t2 = or i16 undef, %t133 ret i16 %t234 }35 36 define void @test5() {ret void}37 38...39---40# CHECK-LABEL: name: test141name: test142alignment: 1643tracksRegLiveness: true44liveins:45 - { reg: '$rax' }46# Verify that "movw ($rax), $ax" is changed to "movzwl ($rax), $rax".47#48# For that to happen, the liveness information after the MOV16rm49# instruction should be used, not before it because $rax is live50# before the MOV and is killed by it.51body: |52 bb.0:53 liveins: $rax54 55 $ax = MOV16rm killed $rax, 1, $noreg, 0, $noreg56 ; CHECK: $eax = MOVZX32rm16 killed $rax57 58 RET64 $ax59 60...61---62# CHECK-LABEL: name: test263name: test264alignment: 1665tracksRegLiveness: true66liveins:67 - { reg: '$rax' }68# Imp-use of any super-register means the register is live before the MOV69body: |70 bb.0:71 liveins: $dl, $rbx, $rcx, $r1472 73 $cl = MOV8rr killed $dl, implicit killed $rcx, implicit-def $rcx74 ; CHECK: $cl = MOV8rr killed $dl, implicit killed $rcx, implicit-def $rcx75 JMP_1 %bb.176 bb.1:77 liveins: $rcx78 79 RET64 $cl80 81...82---83# CHECK-LABEL: name: test384name: test385alignment: 1686tracksRegLiveness: true87liveins:88 - { reg: '$rdi' }89# After MOV16rm the whole $eax is not *really* live, as can be seen by90# missing implicit-uses of it in that MOV. Make sure that MOV is91# transformed into MOVZX.92# See the comment near the original IR on what preceding decisions can93# lead to that.94body: |95 bb.0.entry:96 successors: %bb.1(0x30000000), %bb.2.if.then(0x50000000)97 liveins: $rdi98 99 TEST64rr $rdi, $rdi, implicit-def $eflags100 JCC_1 %bb.1, 4, implicit $eflags101 102 bb.2.if.then:103 liveins: $rdi104 105 $ax = MOV16rm killed $rdi, 1, $noreg, 0, $noreg, implicit-def $eax :: (load (s16) from %ir.p)106 ; CHECK: $eax = MOVZX32rm16 killed $rdi, 1, $noreg, 0, $noreg, implicit-def $eax :: (load (s16) from %ir.p)107 $ax = KILL $ax, implicit killed $eax108 RET64 $ax109 110 bb.1:111 $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags112 $ax = KILL $ax, implicit killed $eax113 RET64 $ax114 115...116---117# CHECK-LABEL: name: test4118name: test4119alignment: 16120tracksRegLiveness: true121liveins:122 - { reg: '$r9d' }123# This code copies r10b into r9b and then uses r9w. We would like to promote124# the copy to a 32-bit copy, but because r9w is used this is not acceptable.125body: |126 bb.0.entry:127 liveins: $r9d128 129 $r9b = MOV8rr undef $r10b, implicit-def $r9d, implicit killed $r9d, implicit-def $eflags130 ; CHECK: $r9b = MOV8rr undef $r10b, implicit-def $r9d, implicit killed $r9d, implicit-def $eflags131 132 $ax = OR16rr undef $ax, $r9w, implicit-def $eflags133 RET64 $ax134 135...136---137# CHECK-LABEL: name: test5138name: test5139alignment: 16140tracksRegLiveness: true141liveins:142 - { reg: '$ch' }143 - { reg: '$bl' }144body: |145 bb.0:146 liveins: $ch, $bl147 148 $cl = MOV8rr $bl, implicit-def $cx, implicit killed $ch, implicit-def $eflags149 ; CHECK: $cl = MOV8rr $bl, implicit-def $cx, implicit killed $ch, implicit-def $eflags150 151 RET64 $cx152 153...154