brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · e48397f Raw
44 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2;3; Test that the fls library call simplifier works correctly even for4; targets with 16-bit int.  Although fls is available on a number of5; targets it's supported (hardcoded as available) only on FreeBSD.6;7; RUN: opt < %s -mtriple=avr-freebsd -passes=instcombine -S | FileCheck %s --check-prefix=AVR8; RUN: opt < %s -mtriple=msp430-freebsd -passes=instcombine -S | FileCheck %s --check-prefix=MSP4309; REQUIRES: avr-registered-target,msp430-registered-target10 11declare i16 @fls(i16)12 13declare void @sink(i16)14 15 16define void @fold_fls(i16 %x) {17; AVR-LABEL: @fold_fls(18; AVR-NEXT:    call addrspace(1) void @sink(i16 0)19; AVR-NEXT:    call addrspace(1) void @sink(i16 1)20; AVR-NEXT:    [[CTLZ:%.*]] = call range(i16 0, 17) addrspace(1) i16 @llvm.ctlz.i16(i16 [[X:%.*]], i1 false)21; AVR-NEXT:    [[NX:%.*]] = sub nuw nsw i16 16, [[CTLZ]]22; AVR-NEXT:    call addrspace(1) void @sink(i16 [[NX]])23; AVR-NEXT:    ret void24;25; MSP430-LABEL: @fold_fls(26; MSP430-NEXT:    call void @sink(i16 0)27; MSP430-NEXT:    call void @sink(i16 1)28; MSP430-NEXT:    [[CTLZ:%.*]] = call range(i16 0, 17) i16 @llvm.ctlz.i16(i16 [[X:%.*]], i1 false)29; MSP430-NEXT:    [[NX:%.*]] = sub nuw nsw i16 16, [[CTLZ]]30; MSP430-NEXT:    call void @sink(i16 [[NX]])31; MSP430-NEXT:    ret void32;33  %n0 = call i16 @fls(i16 0)34  call void @sink(i16 %n0)35 36  %n1 = call i16 @fls(i16 1)37  call void @sink(i16 %n1)38 39  %nx = call i16 @fls(i16 %x)40  call void @sink(i16 %nx)41 42  ret void43}44