mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
ea23b745af
The important thing I was missing was ensuring newly added constants were kept in topological order. Repositioning the node is correct if the constant is newly added (so it has no topological ordering) but wrong if it already existed - positioning it next in the worklist would break the topological ordering. Original commit message: [Thumb] Select a BIC instead of AND if the immediate can be encoded more optimally negated If an immediate is only used in an AND node, it is possible that the immediate can be more optimally materialized when negated. If this is the case, we can negate the immediate and use a BIC instead; int i(int a) { return a & 0xfffffeec; } Used to produce: ldr r1, [CONSTPOOL] ands r0, r1 CONSTPOOL: 0xfffffeec And now produces: movs r1, #255 adds r1, #20 ; Less costly immediate generation bics r0, r1 llvm-svn: 274543
27 lines
686 B
LLVM
27 lines
686 B
LLVM
; RUN: llc < %s -mtriple=thumbv7-linux-gnueabi -mcpu=cortex-m0 -verify-machineinstrs | FileCheck --check-prefix CHECK-T1 %s
|
|
; RUN: llc < %s -mtriple=thumbv7-linux-gnueabi -mcpu=cortex-m3 -verify-machineinstrs | FileCheck --check-prefix CHECK-T2 %s
|
|
|
|
; CHECK-T1-LABEL: @i
|
|
; CHECK-T2-LABEL: @i
|
|
; CHECK-T1: movs r1, #255
|
|
; CHECK-T1: adds r1, #20
|
|
; CHECK-T1: bics r0, r1
|
|
; CHECK-T2: movw r1, #275
|
|
; CHECK-T2: bics r0, r1
|
|
define i32 @i(i32 %a) {
|
|
entry:
|
|
%and = and i32 %a, -276
|
|
ret i32 %and
|
|
}
|
|
|
|
; CHECK-T1-LABEL: @j
|
|
; CHECK-T2-LABEL: @j
|
|
; CHECK-T1: movs r1, #128
|
|
; CHECK-T1: bics r0, r1
|
|
; CHECK-T2: bic r0, r0, #128
|
|
define i32 @j(i32 %a) {
|
|
entry:
|
|
%and = and i32 %a, -129
|
|
ret i32 %and
|
|
}
|