summaryrefslogtreecommitdiff
path: root/test/CodeGen
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>2014-01-13 15:17:53 +0000
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>2014-01-13 15:17:53 +0000
commit80a3301b377a6bdccded883e67ddbfc65cf82d23 (patch)
tree09ff6ddab232685369d1a0dac9fae4fec103ce26 /test/CodeGen
parent1023a9492f36c7cb67d9a36da270beecfb29e15b (diff)
downloadllvm-80a3301b377a6bdccded883e67ddbfc65cf82d23.tar.gz
llvm-80a3301b377a6bdccded883e67ddbfc65cf82d23.tar.bz2
llvm-80a3301b377a6bdccded883e67ddbfc65cf82d23.tar.xz
[SystemZ] Optimize (sext (ashr (shl ...), ...))
...into (ashr (shl (anyext X), ...), ...), which requires one fewer instruction. The (anyext X) can sometimes be simplified too. I didn't do this in DAGCombiner because widening shifts isn't a win on all targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199114 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/SystemZ/shift-10.ll19
1 files changed, 16 insertions, 3 deletions
diff --git a/test/CodeGen/SystemZ/shift-10.ll b/test/CodeGen/SystemZ/shift-10.ll
index 46ed2180df..bf2f0f1776 100644
--- a/test/CodeGen/SystemZ/shift-10.ll
+++ b/test/CodeGen/SystemZ/shift-10.ll
@@ -14,13 +14,14 @@ define i64 @f1(i32 %a) {
ret i64 %ext
}
-; ...and again with the highest shift count.
+; ...and again with the highest shift count that doesn't reduce to an
+; ashr/sext pair.
define i64 @f2(i32 %a) {
; CHECK-LABEL: f2:
-; CHECK: sllg [[REG:%r[0-5]]], %r2, 32
+; CHECK: sllg [[REG:%r[0-5]]], %r2, 33
; CHECK: srag %r2, [[REG]], 63
; CHECK: br %r14
- %shr = lshr i32 %a, 31
+ %shr = lshr i32 %a, 30
%trunc = trunc i32 %shr to i1
%ext = sext i1 %trunc to i64
ret i64 %ext
@@ -76,3 +77,15 @@ define i64 @f6(i64 %a) {
%and = and i64 %shr, 256
ret i64 %and
}
+
+; Test another form of f1.
+define i64 @f7(i32 %a) {
+; CHECK-LABEL: f7:
+; CHECK: sllg [[REG:%r[0-5]]], %r2, 62
+; CHECK: srag %r2, [[REG]], 63
+; CHECK: br %r14
+ %1 = shl i32 %a, 30
+ %sext = ashr i32 %1, 31
+ %ext = sext i32 %sext to i64
+ ret i64 %ext
+}