Skip to content

Commit 59b1e6d

Browse files
committed
[DAGCombiner] Add miscompilation reproducer. NFC.
1 parent 875eec8 commit 59b1e6d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

llvm/test/CodeGen/X86/trunc-nsw-nuw.ll

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,28 @@ entry:
5656
%gep = getelementptr nusw float, ptr %p, i64 %offset
5757
ret ptr %gep
5858
}
59+
60+
; Make sure nsw flag is dropped after we simplify the operand of TRUNCATE.
61+
62+
define i32 @simplify_demanded_bits_drop_flag(i1 zeroext %x, i1 zeroext %y) nounwind {
63+
; CHECK-LABEL: simplify_demanded_bits_drop_flag:
64+
; CHECK: # %bb.0: # %entry
65+
; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
66+
; CHECK-NEXT: negl %edi
67+
; CHECK-NEXT: shll $2, %esi
68+
; CHECK-NEXT: xorl %edi, %esi
69+
; CHECK-NEXT: imulq $-1634202141, %rsi, %rax # imm = 0x9E980DE3
70+
; CHECK-NEXT: movq %rax, %rcx
71+
; CHECK-NEXT: shrq $63, %rcx
72+
; CHECK-NEXT: sarq $44, %rax
73+
; CHECK-NEXT: addl %ecx, %eax
74+
; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
75+
; CHECK-NEXT: retq
76+
entry:
77+
%sel = select i1 %y, i64 4, i64 0
78+
%conv0 = sext i1 %x to i64
79+
%xor = xor i64 %sel, %conv0
80+
%conv1 = trunc nsw i64 %xor to i32
81+
%div = sdiv i32 %conv1, -10765
82+
ret i32 %div
83+
}

0 commit comments

Comments
 (0)