xref: /llvm-project/llvm/test/Transforms/InstCombine/puts-i16.ll (revision 1e029cf53bc9fb1894824363634323f0ed51c5a8)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2;
3; RUN: opt < %s -mtriple=avr-linux -passes=instcombine -S | FileCheck %s --check-prefix=AVR
4; RUN: opt < %s -mtriple=msp430-freebsd -passes=instcombine -S | FileCheck %s --check-prefix=MSP430
5; REQUIRES: avr-registered-target,msp430-registered-target
6;
7; Test that the puts to putchar transformation works correctly even for
8; targets with 16-bit int.
9
10declare i16 @putchar(i16)
11declare i16 @puts(ptr)
12
13@empty = constant [1 x i8] c"\00"
14
15define void @xform_puts(i16 %c) {
16; Transform puts("") to putchar("\n").
17; AVR-LABEL: @xform_puts(
18; AVR-NEXT:    [[PUTCHAR:%.*]] = call addrspace(1) i16 @putchar(i16 10)
19; AVR-NEXT:    ret void
20;
21; MSP430-LABEL: @xform_puts(
22; MSP430-NEXT:    [[PUTCHAR:%.*]] = call i16 @putchar(i16 10)
23; MSP430-NEXT:    ret void
24;
25  call i16 @puts(ptr @empty)
26
27  ret void
28}
29