2016-08-04 02:17:35 +08:00
|
|
|
; RUN: llc -verify-machineinstrs -mcpu=pwr7 < %s | FileCheck %s
|
2017-01-17 04:12:26 +08:00
|
|
|
; RUN: llc -verify-machineinstrs -mcpu=pwr7 -ppc-gen-isel=false < %s | FileCheck --check-prefix=CHECK-NO-ISEL %s
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
target datalayout = "E-m:e-i64:64-n32:64"
|
|
|
|
target triple = "powerpc64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
define signext i32 @foo(i32 signext %a, i32 signext %b) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp slt i32 %a, %b
|
|
|
|
%conv = zext i1 %cmp to i32
|
|
|
|
%shl = shl nuw nsw i32 %conv, 4
|
|
|
|
ret i32 %shl
|
|
|
|
|
|
|
|
; CHECK-LABEL: @foo
|
2017-01-17 04:12:26 +08:00
|
|
|
; CHECK-NO-ISEL-LABEL: @foo
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
; CHECK-DAG: cmpw
|
|
|
|
; CHECK-DAG: li [[REG1:[0-9]+]], 0
|
|
|
|
; CHECK-DAG: li [[REG2:[0-9]+]], 16
|
|
|
|
; CHECK: isel 3, [[REG2]], [[REG1]],
|
|
|
|
; CHECK: blr
|
2017-01-17 04:12:26 +08:00
|
|
|
|
|
|
|
; CHECK-NO-ISEL: bc 12, 0, [[TRUE:.LBB[0-9]+]]
|
|
|
|
; CHECK-NO-ISEL: ori 3, 5, 0
|
|
|
|
; CHECK-NO-ISEL-NEXT: blr
|
|
|
|
; CHECK-NO-ISEL-NEXT: [[TRUE]]
|
|
|
|
; CHECK-NO-ISEL-NEXT: addi 3, 12, 0
|
|
|
|
; CHECK-NO-ISEL-NEXT: blr
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
define signext i32 @foo2(i32 signext %a, i32 signext %b) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp slt i32 %a, %b
|
|
|
|
%conv = zext i1 %cmp to i32
|
|
|
|
%shl = shl nuw nsw i32 %conv, 4
|
|
|
|
%add1 = or i32 %shl, 5
|
|
|
|
ret i32 %add1
|
|
|
|
|
|
|
|
; CHECK-LABEL: @foo2
|
2017-01-17 04:12:26 +08:00
|
|
|
; CHECK-NO-ISEL-LABEL: @foo2
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
; CHECK-DAG: cmpw
|
|
|
|
; CHECK-DAG: li [[REG1:[0-9]+]], 5
|
|
|
|
; CHECK-DAG: li [[REG2:[0-9]+]], 21
|
|
|
|
; CHECK: isel 3, [[REG2]], [[REG1]],
|
|
|
|
; CHECK: blr
|
2017-01-17 04:12:26 +08:00
|
|
|
|
|
|
|
; CHECK-NO-ISEL: bc 12, 0, [[TRUE:.LBB[0-9]+]]
|
|
|
|
; CHECK-NO-ISEL: ori 3, 5, 0
|
|
|
|
; CHECK-NO-ISEL-NEXT: blr
|
|
|
|
; CHECK-NO-ISEL-NEXT: [[TRUE]]
|
|
|
|
; CHECK-NO-ISEL-NEXT: addi 3, 12, 0
|
|
|
|
; CHECK-NO-ISEL-NEXT: blr
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
|
|
|
define signext i32 @foo3(i32 signext %a, i32 signext %b) #0 {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sle i32 %a, %b
|
|
|
|
%conv = zext i1 %cmp to i32
|
|
|
|
%shl = shl nuw nsw i32 %conv, 4
|
|
|
|
ret i32 %shl
|
|
|
|
|
|
|
|
; CHECK-LABEL: @foo3
|
2017-01-17 04:12:26 +08:00
|
|
|
; CHECK-NO-ISEL-LABEL: @foo3
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
; CHECK-DAG: cmpw
|
|
|
|
; CHECK-DAG: li [[REG1:[0-9]+]], 16
|
|
|
|
; CHECK: isel 3, 0, [[REG1]],
|
|
|
|
; CHECK: blr
|
2017-01-17 04:12:26 +08:00
|
|
|
|
|
|
|
; CHECK-NO-ISEL: bc 12, 1, [[TRUE:.LBB[0-9]+]]
|
|
|
|
; CHECK-NO-ISEL: ori 3, 5, 0
|
|
|
|
; CHECK-NO-ISEL-NEXT: blr
|
|
|
|
; CHECK-NO-ISEL-NEXT: [[TRUE]]
|
|
|
|
; CHECK-NO-ISEL-NEXT: addi 3, 0, 0
|
|
|
|
; CHECK-NO-ISEL-NEXT: blr
|
[PowerPC] Fold i1 extensions with other ops
Consider this function from our README.txt file:
int foo(int a, int b) { return (a < b) << 4; }
We now explicitly track CR bits by default, so the comment in the README.txt
about not really having a SETCC is no longer accurate, but we did generate this
somewhat silly code:
cmpw 0, 3, 4
li 3, 0
li 12, 1
isel 3, 12, 3, 0
sldi 3, 3, 4
blr
which generates the zext as a select between 0 and 1, and then shifts the
result by a constant amount. Here we preprocess the DAG in order to fold the
results of operations on an extension of an i1 value into the SELECT_I[48]
pseudo instruction when the resulting constant can be materialized using one
instruction (just like the 0 and 1). This was not implemented as a DAGCombine
because the resulting code would have been anti-canonical and depends on
replacing chained user nodes, which does not fit well into the lowering
paradigm. Now we generate:
cmpw 0, 3, 4
li 3, 0
li 12, 16
isel 3, 12, 3, 0
blr
which is less silly.
llvm-svn: 225203
2015-01-06 05:10:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind readnone }
|
|
|
|
|