Skip to content

Commit fabf7fe

Browse files
committedAug 15, 2018
[ARM] TypeSize lower bound for ARMCodeGenPrepare
We only try to promote types with are smaller than 16-bits, but we also need to check that the type is not less than 8-bits. Differential Revision: https://reviews.llvm.org/D50769 llvm-svn: 339770
1 parent 8b4bd09 commit fabf7fe

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
 

‎llvm/lib/Target/ARM/ARMCodeGenPrepare.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ bool ARMCodeGenPrepare::isLegalToPromote(Value *V) {
562562
bool ARMCodeGenPrepare::TryToPromote(Value *V) {
563563
OrigTy = V->getType();
564564
TypeSize = OrigTy->getPrimitiveSizeInBits();
565-
if (TypeSize > 16)
565+
if (TypeSize > 16 || TypeSize < 8)
566566
return false;
567567

568568
if (!isSupportedValue(V) || !shouldPromote(V) || !isLegalToPromote(V))

‎llvm/test/CodeGen/ARM/arm-cgp-icmps.ll

+24
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,27 @@ define i32 @icmp_not(i16 zeroext %arg0, i16 zeroext %arg1) {
256256
ret i32 %res
257257
}
258258

259+
; CHECK-COMMON-LABEL: icmp_i1
260+
; CHECK-NOT: uxt
261+
define i32 @icmp_i1(i1* %arg0, i1 zeroext %arg1, i32 %a, i32 %b) {
262+
entry:
263+
%load = load i1, i1* %arg0
264+
%not = xor i1 %load, 1
265+
%cmp = icmp eq i1 %arg1, %not
266+
%res = select i1 %cmp, i32 %a, i32 %b
267+
ret i32 %res
268+
}
269+
270+
; CHECK-COMMON-LABEL: icmp_i7
271+
; CHECK-COMMON: ldrb
272+
; CHECK-COMMON: and
273+
; CHECK-COMMON: cmp
274+
define i32 @icmp_i7(i7* %arg0, i7 zeroext %arg1, i32 %a, i32 %b) {
275+
entry:
276+
%load = load i7, i7* %arg0
277+
%add = add nuw i7 %load, 1
278+
%cmp = icmp ult i7 %arg1, %add
279+
%res = select i1 %cmp, i32 %a, i32 %b
280+
ret i32 %res
281+
}
282+

0 commit comments

Comments
 (0)
Please sign in to comment.