2017-02-12 03:27:15 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
2016-09-15 03:42:03 +08:00
|
|
|
; RUN: llc < %s -mtriple=i386-unknown-unknown -disable-cgp-branch-opts | FileCheck %s --check-prefix=CHECK --check-prefix=X32
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -disable-cgp-branch-opts | FileCheck %s --check-prefix=CHECK --check-prefix=X64
|
|
|
|
|
2010-01-26 10:00:44 +08:00
|
|
|
; rdar://7573216
|
2010-01-28 09:57:22 +08:00
|
|
|
; PR6146
|
2010-01-26 10:00:44 +08:00
|
|
|
|
|
|
|
define i32 @t1(i32 %x) nounwind readnone ssp {
|
2017-02-12 03:27:15 +08:00
|
|
|
; X32-LABEL: t1:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2017-02-12 03:27:15 +08:00
|
|
|
; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
|
|
|
|
; X32-NEXT: sbbl %eax, %eax
|
|
|
|
; X32-NEXT: retl
|
2016-09-15 03:42:03 +08:00
|
|
|
;
|
2017-02-12 03:27:15 +08:00
|
|
|
; X64-LABEL: t1:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2017-02-12 03:27:15 +08:00
|
|
|
; X64-NEXT: cmpl $1, %edi
|
|
|
|
; X64-NEXT: sbbl %eax, %eax
|
|
|
|
; X64-NEXT: retq
|
2016-09-15 03:42:03 +08:00
|
|
|
%t0 = icmp eq i32 %x, 0
|
|
|
|
%if = select i1 %t0, i32 -1, i32 0
|
|
|
|
ret i32 %if
|
2010-01-26 10:00:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @t2(i32 %x) nounwind readnone ssp {
|
2017-02-12 03:27:15 +08:00
|
|
|
; X32-LABEL: t2:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2017-02-12 03:27:15 +08:00
|
|
|
; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
|
|
|
|
; X32-NEXT: sbbl %eax, %eax
|
|
|
|
; X32-NEXT: retl
|
2016-09-15 03:42:03 +08:00
|
|
|
;
|
2017-02-12 03:27:15 +08:00
|
|
|
; X64-LABEL: t2:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2017-02-12 03:27:15 +08:00
|
|
|
; X64-NEXT: cmpl $1, %edi
|
|
|
|
; X64-NEXT: sbbl %eax, %eax
|
|
|
|
; X64-NEXT: retq
|
2016-09-15 03:42:03 +08:00
|
|
|
%t0 = icmp eq i32 %x, 0
|
|
|
|
%if = sext i1 %t0 to i32
|
|
|
|
ret i32 %if
|
2010-01-26 10:00:44 +08:00
|
|
|
}
|
2010-01-28 09:57:22 +08:00
|
|
|
|
2019-03-14 02:36:59 +08:00
|
|
|
define i32 @t3(i32 %x) nounwind readonly {
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-LABEL: t3:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0: # %entry
|
2019-03-14 02:36:59 +08:00
|
|
|
; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-NEXT: sbbl %eax, %eax
|
|
|
|
; X32-NEXT: cmpl %eax, %eax
|
|
|
|
; X32-NEXT: sbbl %eax, %eax
|
|
|
|
; X32-NEXT: xorl %eax, %eax
|
|
|
|
; X32-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: t3:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0: # %entry
|
2017-08-11 23:44:14 +08:00
|
|
|
; X64-NEXT: xorl %eax, %eax
|
2019-03-14 02:36:59 +08:00
|
|
|
; X64-NEXT: testl %edi, %edi
|
2017-08-11 23:44:14 +08:00
|
|
|
; X64-NEXT: sete %al
|
|
|
|
; X64-NEXT: negq %rax
|
2016-09-15 03:42:03 +08:00
|
|
|
; X64-NEXT: cmpq %rax, %rax
|
|
|
|
; X64-NEXT: xorl %eax, %eax
|
|
|
|
; X64-NEXT: retq
|
2010-01-28 09:57:22 +08:00
|
|
|
entry:
|
2019-03-14 02:36:59 +08:00
|
|
|
%not.tobool = icmp eq i32 %x, 0
|
2016-09-15 03:42:03 +08:00
|
|
|
%cond = sext i1 %not.tobool to i32
|
|
|
|
%conv = sext i1 %not.tobool to i64
|
|
|
|
%add13 = add i64 0, %conv
|
|
|
|
%cmp = icmp ult i64 undef, %add13
|
2010-01-28 09:57:22 +08:00
|
|
|
br i1 %cmp, label %if.then, label %if.end
|
|
|
|
|
2016-09-15 03:42:03 +08:00
|
|
|
if.then:
|
2010-01-28 09:57:22 +08:00
|
|
|
br label %if.end
|
|
|
|
|
2016-09-15 03:42:03 +08:00
|
|
|
if.end:
|
|
|
|
%xor27 = xor i32 undef, %cond
|
2010-01-28 09:57:22 +08:00
|
|
|
ret i32 0
|
|
|
|
}
|
[DAGCombine] Remove SIGN_EXTEND-related inf-loop
The patch's author points out that, despite the function's documentation,
getSetCCResultType is only used to get the SETCC result type (with one
here-removed problematic exception). In one case, getSetCCResultType was being
used to get the predicate type to use for a SELECT node, and then
SIGN_EXTENDing (or truncating) to get the input predicate to match that type.
Unfortunately, this was happening inside visitSIGN_EXTEND, and creating new
SIGN_EXTEND nodes was causing an infinite loop. In addition, this behavior was
wrong if a target was not using ZeroOrNegativeOneBooleanContent. Lastly, the
extension/truncation seems unnecessary here: SELECT is defined as:
Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not i1
then the high bits must conform to getBooleanContents.
So here we remove this use of getSetCCResultType and update
getSetCCResultType's documentation to reflect its actual uses.
Patch by deadal nix!
llvm-svn: 219141
2014-10-07 04:19:47 +08:00
|
|
|
|
|
|
|
define i32 @t4(i64 %x) nounwind readnone ssp {
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-LABEL: t4:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2017-08-11 23:44:14 +08:00
|
|
|
; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-NEXT: xorl %eax, %eax
|
2017-08-11 23:44:14 +08:00
|
|
|
; X32-NEXT: orl {{[0-9]+}}(%esp), %ecx
|
|
|
|
; X32-NEXT: sete %al
|
|
|
|
; X32-NEXT: negl %eax
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: t4:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2016-09-15 03:42:03 +08:00
|
|
|
; X64-NEXT: cmpq $1, %rdi
|
|
|
|
; X64-NEXT: sbbl %eax, %eax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
%t0 = icmp eq i64 %x, 0
|
|
|
|
%t1 = sext i1 %t0 to i32
|
|
|
|
ret i32 %t1
|
[DAGCombine] Remove SIGN_EXTEND-related inf-loop
The patch's author points out that, despite the function's documentation,
getSetCCResultType is only used to get the SETCC result type (with one
here-removed problematic exception). In one case, getSetCCResultType was being
used to get the predicate type to use for a SELECT node, and then
SIGN_EXTENDing (or truncating) to get the input predicate to match that type.
Unfortunately, this was happening inside visitSIGN_EXTEND, and creating new
SIGN_EXTEND nodes was causing an infinite loop. In addition, this behavior was
wrong if a target was not using ZeroOrNegativeOneBooleanContent. Lastly, the
extension/truncation seems unnecessary here: SELECT is defined as:
Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not i1
then the high bits must conform to getBooleanContents.
So here we remove this use of getSetCCResultType and update
getSetCCResultType's documentation to reflect its actual uses.
Patch by deadal nix!
llvm-svn: 219141
2014-10-07 04:19:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @t5(i32 %x) nounwind readnone ssp {
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-LABEL: t5:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2016-09-15 03:42:03 +08:00
|
|
|
; X32-NEXT: cmpl $1, {{[0-9]+}}(%esp)
|
|
|
|
; X32-NEXT: sbbl %eax, %eax
|
|
|
|
; X32-NEXT: movl %eax, %edx
|
|
|
|
; X32-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: t5:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2016-09-15 03:42:03 +08:00
|
|
|
; X64-NEXT: cmpl $1, %edi
|
|
|
|
; X64-NEXT: sbbq %rax, %rax
|
|
|
|
; X64-NEXT: retq
|
|
|
|
%t0 = icmp eq i32 %x, 0
|
|
|
|
%t1 = sext i1 %t0 to i64
|
|
|
|
ret i64 %t1
|
[DAGCombine] Remove SIGN_EXTEND-related inf-loop
The patch's author points out that, despite the function's documentation,
getSetCCResultType is only used to get the SETCC result type (with one
here-removed problematic exception). In one case, getSetCCResultType was being
used to get the predicate type to use for a SELECT node, and then
SIGN_EXTENDing (or truncating) to get the input predicate to match that type.
Unfortunately, this was happening inside visitSIGN_EXTEND, and creating new
SIGN_EXTEND nodes was causing an infinite loop. In addition, this behavior was
wrong if a target was not using ZeroOrNegativeOneBooleanContent. Lastly, the
extension/truncation seems unnecessary here: SELECT is defined as:
Select(COND, TRUEVAL, FALSEVAL). If the type of the boolean COND is not i1
then the high bits must conform to getBooleanContents.
So here we remove this use of getSetCCResultType and update
getSetCCResultType's documentation to reflect its actual uses.
Patch by deadal nix!
llvm-svn: 219141
2014-10-07 04:19:47 +08:00
|
|
|
}
|
|
|
|
|
2017-02-19 05:07:37 +08:00
|
|
|
; sext (xor Bool, -1) --> sub (zext Bool), 1
|
2017-02-18 05:10:40 +08:00
|
|
|
|
|
|
|
define i32 @select_0_or_1s(i1 %cond) {
|
|
|
|
; X32-LABEL: select_0_or_1s:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2017-02-19 05:03:28 +08:00
|
|
|
; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X32-NEXT: andl $1, %eax
|
2017-02-19 05:03:28 +08:00
|
|
|
; X32-NEXT: decl %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: select_0_or_1s:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2017-02-19 05:03:28 +08:00
|
|
|
; X64-NEXT: andl $1, %edi
|
|
|
|
; X64-NEXT: leal -1(%rdi), %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X64-NEXT: retq
|
|
|
|
%not = xor i1 %cond, 1
|
|
|
|
%sext = sext i1 %not to i32
|
|
|
|
ret i32 %sext
|
|
|
|
}
|
|
|
|
|
2017-02-19 05:07:37 +08:00
|
|
|
; sext (xor Bool, -1) --> sub (zext Bool), 1
|
2017-02-18 05:10:40 +08:00
|
|
|
|
|
|
|
define i32 @select_0_or_1s_zeroext(i1 zeroext %cond) {
|
|
|
|
; X32-LABEL: select_0_or_1s_zeroext:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2017-02-19 05:03:28 +08:00
|
|
|
; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X32-NEXT: decl %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: select_0_or_1s_zeroext:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2018-02-01 06:04:26 +08:00
|
|
|
; X64-NEXT: # kill: def $edi killed $edi def $rdi
|
2017-09-19 06:05:35 +08:00
|
|
|
; X64-NEXT: leal -1(%rdi), %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X64-NEXT: retq
|
|
|
|
%not = xor i1 %cond, 1
|
|
|
|
%sext = sext i1 %not to i32
|
|
|
|
ret i32 %sext
|
|
|
|
}
|
|
|
|
|
2017-02-19 05:07:37 +08:00
|
|
|
; sext (xor Bool, -1) --> sub (zext Bool), 1
|
2017-02-18 05:10:40 +08:00
|
|
|
|
|
|
|
define i32 @select_0_or_1s_signext(i1 signext %cond) {
|
|
|
|
; X32-LABEL: select_0_or_1s_signext:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X32: # %bb.0:
|
2018-03-02 06:32:25 +08:00
|
|
|
; X32-NEXT: movzbl {{[0-9]+}}(%esp), %eax
|
|
|
|
; X32-NEXT: andl $1, %eax
|
2017-02-19 05:03:28 +08:00
|
|
|
; X32-NEXT: decl %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X32-NEXT: retl
|
|
|
|
;
|
|
|
|
; X64-LABEL: select_0_or_1s_signext:
|
2017-12-05 01:18:51 +08:00
|
|
|
; X64: # %bb.0:
|
2017-10-09 23:22:20 +08:00
|
|
|
; X64-NEXT: movl %edi, %eax
|
2018-09-20 02:59:08 +08:00
|
|
|
; X64-NEXT: notl %eax
|
2017-02-18 05:10:40 +08:00
|
|
|
; X64-NEXT: retq
|
|
|
|
%not = xor i1 %cond, 1
|
|
|
|
%sext = sext i1 %not to i32
|
|
|
|
ret i32 %sext
|
|
|
|
}
|
|
|
|
|