Skip to content

Commit 36d5281

Browse files
committed
[X86][test] Pre-commit test for an incorrect pattern for CCMP/CTEST with imm64
1 parent 9a5a873 commit 36d5281

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

llvm/test/CodeGen/X86/apx/ccmp.ll

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,5 +1254,49 @@ entry:
12541254
ret i32 %.
12551255
}
12561256

1257+
define void @ccmp64ri64(i64 noundef %a, i64 noundef %b, i64 noundef %c) {
1258+
; CHECK-LABEL: ccmp64ri64:
1259+
; CHECK: # %bb.0: # %entry
1260+
; CHECK-NEXT: cmpq %rdx, %rdi # encoding: [0x48,0x39,0xd7]
1261+
; CHECK-NEXT: ccmpbeq {dfv=zf} $9992147483646, %rsi # encoding: [0x62,0xf4,0x94,0x06,0x81,0xfe,0xfe,0xbb,0x66,0x7a]
1262+
; CHECK-NEXT: # imm = 0x9167A66BBFE
1263+
; CHECK-NEXT: jg .LBB30_1 # encoding: [0x7f,A]
1264+
; CHECK-NEXT: # fixup A - offset: 1, value: .LBB30_1-1, kind: FK_PCRel_1
1265+
; CHECK-NEXT: # %bb.2: # %if.then
1266+
; CHECK-NEXT: xorl %eax, %eax # encoding: [0x31,0xc0]
1267+
; CHECK-NEXT: jmp foo # TAILCALL
1268+
; CHECK-NEXT: # encoding: [0xeb,A]
1269+
; CHECK-NEXT: # fixup A - offset: 1, value: foo-1, kind: FK_PCRel_1
1270+
; CHECK-NEXT: .LBB30_1: # %if.end
1271+
; CHECK-NEXT: retq # encoding: [0xc3]
1272+
;
1273+
; NDD-LABEL: ccmp64ri64:
1274+
; NDD: # %bb.0: # %entry
1275+
; NDD-NEXT: cmpq %rdx, %rdi # encoding: [0x48,0x39,0xd7]
1276+
; NDD-NEXT: ccmpbeq {dfv=zf} $9992147483646, %rsi # encoding: [0x62,0xf4,0x94,0x06,0x81,0xfe,0xfe,0xbb,0x66,0x7a]
1277+
; NDD-NEXT: # imm = 0x9167A66BBFE
1278+
; NDD-NEXT: jg .LBB30_1 # encoding: [0x7f,A]
1279+
; NDD-NEXT: # fixup A - offset: 1, value: .LBB30_1-1, kind: FK_PCRel_1
1280+
; NDD-NEXT: # %bb.2: # %if.then
1281+
; NDD-NEXT: xorl %eax, %eax # encoding: [0x31,0xc0]
1282+
; NDD-NEXT: jmp foo # TAILCALL
1283+
; NDD-NEXT: # encoding: [0xeb,A]
1284+
; NDD-NEXT: # fixup A - offset: 1, value: foo-1, kind: FK_PCRel_1
1285+
; NDD-NEXT: .LBB30_1: # %if.end
1286+
; NDD-NEXT: retq # encoding: [0xc3]
1287+
entry:
1288+
%cmp = icmp ugt i64 %a, %c
1289+
%cmp1 = icmp slt i64 %b, 9992147483647
1290+
%or.cond = or i1 %cmp, %cmp1
1291+
br i1 %or.cond, label %if.then, label %if.end
1292+
1293+
if.then: ; preds = %entry
1294+
tail call void (...) @foo()
1295+
br label %if.end
1296+
1297+
if.end: ; preds = %entry, %if.then
1298+
ret void
1299+
}
1300+
12571301
declare dso_local void @foo(...)
12581302
declare {i64, i1} @llvm.ssub.with.overflow.i64(i64, i64) nounwind readnone

llvm/test/CodeGen/X86/apx/ctest.ll

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,4 +897,41 @@ entry:
897897
ret i32 %.
898898
}
899899

900+
define void @ctest64ri64(i64 noundef %a, i64 noundef %b) {
901+
; CHECK-LABEL: ctest64ri64:
902+
; CHECK: # %bb.0: # %entry
903+
; CHECK-NEXT: testq %rdi, %rdi
904+
; CHECK-NEXT: ctestneq {dfv=zf} $9992147483647, %rsi # imm = 0x9167A66BBFF
905+
; CHECK-NEXT: jne .LBB24_1
906+
; CHECK-NEXT: # %bb.2: # %if.then
907+
; CHECK-NEXT: xorl %eax, %eax
908+
; CHECK-NEXT: jmp foo # TAILCALL
909+
; CHECK-NEXT: .LBB24_1: # %if.end
910+
; CHECK-NEXT: retq
911+
;
912+
; NDD-LABEL: ctest64ri64:
913+
; NDD: # %bb.0: # %entry
914+
; NDD-NEXT: testq %rdi, %rdi
915+
; NDD-NEXT: ctestneq {dfv=zf} $9992147483647, %rsi # imm = 0x9167A66BBFF
916+
; NDD-NEXT: jne .LBB24_1
917+
; NDD-NEXT: # %bb.2: # %if.then
918+
; NDD-NEXT: xorl %eax, %eax
919+
; NDD-NEXT: jmp foo # TAILCALL
920+
; NDD-NEXT: .LBB24_1: # %if.end
921+
; NDD-NEXT: retq
922+
entry:
923+
%cmp = icmp eq i64 %a, 0
924+
%and = and i64 %b, 9992147483647
925+
%cmp1 = icmp eq i64 %and, 0
926+
%or.cond = or i1 %cmp, %cmp1
927+
br i1 %or.cond, label %if.then, label %if.end
928+
929+
if.then: ; preds = %entry
930+
tail call void (...) @foo()
931+
br label %if.end
932+
933+
if.end: ; preds = %entry, %if.then
934+
ret void
935+
}
936+
900937
declare dso_local void @foo(...)

0 commit comments

Comments
 (0)