1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00
llvm-mirror/test/CodeGen/ARM/add-like-or.ll
Tim Northover 63b281a203 ARM: convert ORR instructions to ADD where possible on Thumb.
Thumb has more 16-bit encoding space dedicated to ADD than ORR, allowing both a
3-address encoding and a wider range of immediates. So, particularly when
optimizing for code size (but it doesn't make things worse elsewhere) it's
beneficial to select an OR operation to an ADD if we know overflow won't occur.

This is made even better by LLVM's penchant for putting operations in canonical
form by converting the other way.

llvm-svn: 335119
2018-06-20 12:09:44 +00:00

42 lines
1.1 KiB
LLVM

; RUN: llc -mtriple=thumbv6m-apple-macho %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-T1
; RUN: llc -mtriple=thumbv7m-apple-macho %s -o - | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-T2
define i32 @test_add_i3(i1 %tst, i32 %a, i32 %b) {
; CHECK-LABEL: test_add_i3:
; CHECK: adds r0, {{r[0-9]+}}, #2
%tmp = and i32 %a, -7
%tmp1 = and i32 %b, -4
%int = select i1 %tst, i32 %tmp, i32 %tmp1
; Call to force %int into a register that isn't r0 so using the i3 form is a
; good idea.
call void @foo(i32 %int)
%res = or i32 %int, 2
ret i32 %res
}
define i32 @test_add_i8(i32 %a, i32 %b, i1 %tst) {
; CHECK-LABEL: test_add_i8:
; CHECK-T1: adds r0, #12
; CHECK-T2: add.w r0, {{r[0-9]+}}, #12
%tmp = and i32 %a, -256
%tmp1 = and i32 %b, -512
%int = select i1 %tst, i32 %tmp, i32 %tmp1
%res = or i32 %int, 12
ret i32 %res
}
define i32 @test_add_i12(i32 %a, i32 %b, i1 %tst) {
; CHECK-LABEL: test_add_i12:
; CHECK-T2: addw r0, {{r[0-9]+}}, #854
%tmp = and i32 %a, -4096
%tmp1 = and i32 %b, -8192
%int = select i1 %tst, i32 %tmp, i32 %tmp1
%res = or i32 %int, 854
ret i32 %res
}
declare void @foo(i32)