1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=m68k-linux -verify-machineinstrs | FileCheck %s 3 4;; TODO All these can be improved 5 6define zeroext i16 @t1(i16 zeroext %x) nounwind readnone ssp { 7; CHECK-LABEL: t1: 8; CHECK: ; %bb.0: ; %entry 9; CHECK-NEXT: move.w (6,%sp), %d0 10; CHECK-NEXT: and.l #65535, %d0 11; CHECK-NEXT: sub.l #26, %d0 12; CHECK-NEXT: shi %d0 13; CHECK-NEXT: and.l #255, %d0 14; CHECK-NEXT: lsl.l #5, %d0 15; CHECK-NEXT: rts 16entry: 17 %0 = icmp ugt i16 %x, 26 ; <i1> [#uses=1] 18 %iftmp.1.0 = select i1 %0, i16 32, i16 0 ; <i16> [#uses=1] 19 ret i16 %iftmp.1.0 20} 21 22define zeroext i16 @t2(i16 zeroext %x) nounwind readnone ssp { 23; CHECK-LABEL: t2: 24; CHECK: ; %bb.0: ; %entry 25; CHECK-NEXT: move.w (6,%sp), %d0 26; CHECK-NEXT: and.l #65535, %d0 27; CHECK-NEXT: sub.l #26, %d0 28; CHECK-NEXT: scs %d0 29; CHECK-NEXT: and.l #255, %d0 30; CHECK-NEXT: lsl.l #5, %d0 31; CHECK-NEXT: rts 32entry: 33 %0 = icmp ult i16 %x, 26 ; <i1> [#uses=1] 34 %iftmp.0.0 = select i1 %0, i16 32, i16 0 ; <i16> [#uses=1] 35 ret i16 %iftmp.0.0 36} 37 38define fastcc i64 @t3(i64 %x) nounwind readnone ssp { 39; CHECK-LABEL: t3: 40; CHECK: ; %bb.0: ; %entry 41; CHECK-NEXT: suba.l #4, %sp 42; CHECK-NEXT: movem.l %d2, (0,%sp) ; 8-byte Folded Spill 43; CHECK-NEXT: move.l #0, %d2 44; CHECK-NEXT: sub.l #18, %d1 45; CHECK-NEXT: subx.l %d2, %d0 46; CHECK-NEXT: scs %d0 47; CHECK-NEXT: move.l %d0, %d1 48; CHECK-NEXT: and.l #255, %d1 49; CHECK-NEXT: and.l #1, %d1 50; CHECK-NEXT: lsl.l #6, %d1 51; CHECK-NEXT: move.l %d2, %d0 52; CHECK-NEXT: movem.l (0,%sp), %d2 ; 8-byte Folded Reload 53; CHECK-NEXT: adda.l #4, %sp 54; CHECK-NEXT: rts 55entry: 56 %0 = icmp ult i64 %x, 18 ; <i1> [#uses=1] 57 %iftmp.2.0 = select i1 %0, i64 64, i64 0 ; <i64> [#uses=1] 58 ret i64 %iftmp.2.0 59} 60 61define i8 @t5(i32 %a) { 62; CHECK-LABEL: t5: 63; CHECK: .cfi_startproc 64; CHECK-NEXT: ; %bb.0: ; %entry 65; CHECK-NEXT: move.l #31, %d1 66; CHECK-NEXT: move.l (4,%sp), %d0 67; CHECK-NEXT: lsr.l %d1, %d0 68; CHECK-NEXT: eori.b #1, %d0 69; CHECK-NEXT: ; kill: def $bd0 killed $bd0 killed $d0 70; CHECK-NEXT: rts 71entry: 72 %.lobit = lshr i32 %a, 31 73 %trunc = trunc i32 %.lobit to i8 74 %.not = xor i8 %trunc, 1 75 ret i8 %.not 76} 77 78 79; 80; TODO: Should it be like this? 81; cmp.l 82; smi 83; since we are intereseted in sign bit only 84; and.l in the end is superfluous 85 86define zeroext i1 @t6(i32 %a) { 87; CHECK-LABEL: t6: 88; CHECK: .cfi_startproc 89; CHECK-NEXT: ; %bb.0: ; %entry 90; CHECK-NEXT: move.l #31, %d0 91; CHECK-NEXT: move.l (4,%sp), %d1 92; CHECK-NEXT: lsr.l %d0, %d1 93; CHECK-NEXT: eori.b #1, %d1 94; CHECK-NEXT: move.l %d1, %d0 95; CHECK-NEXT: and.l #255, %d0 96; CHECK-NEXT: rts 97entry: 98 %.lobit = lshr i32 %a, 31 99 %trunc = trunc i32 %.lobit to i1 100 %.not = xor i1 %trunc, 1 101 ret i1 %.not 102} 103