Fix revsh pattern.
authorEvan Cheng <evan.cheng@apple.com>
Tue, 18 Aug 2009 05:43:23 +0000 (05:43 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Tue, 18 Aug 2009 05:43:23 +0000 (05:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79318 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMInstrThumb.td
lib/Target/ARM/ARMInstrThumb2.td
test/CodeGen/Thumb2/thumb2-rev.ll

index 48f3eee488c2904e248737113f823a650c771589..bae9afe9092ef2ef1df110668a922d6b1c9dfdad 100644 (file)
@@ -543,7 +543,7 @@ def tREVSH : T1pI<(outs tGPR:$dst), (ins tGPR:$src), IIC_iALU,
                   "revsh", " $dst, $src",
                   [(set tGPR:$dst,
                         (sext_inreg
-                          (or (srl (and tGPR:$src, 0xFFFF), (i32 8)),
+                          (or (srl (and tGPR:$src, 0xFF00), (i32 8)),
                               (shl tGPR:$src, (i32 8))), i16))]>,
                   Requires<[IsThumb1Only, HasV6]>;
 
index 840a6bb0130f660bc11ec99cf16013cbb55e22dd..1eafd2e2f9a9ec6171d6a3a9c9781329f2e7297a 100644 (file)
@@ -951,7 +951,7 @@ def t2REVSH : T2I<(outs GPR:$dst), (ins GPR:$src), IIC_iALU,
                  "revsh", ".w $dst, $src",
                  [(set GPR:$dst,
                     (sext_inreg
-                      (or (srl (and GPR:$src, 0xFFFF), (i32 8)),
+                      (or (srl (and GPR:$src, 0xFF00), (i32 8)),
                           (shl GPR:$src, (i32 8))), i16))]>;
 
 def t2PKHBT : T2I<(outs GPR:$dst), (ins GPR:$src1, GPR:$src2, i32imm:$shamt),
index c1bdc382e1469b53422dfa103f0cfcd4a0ff1d25..4205ed1a3fdaf2ced1b1be5aa47b4ad3f587d8b4 100644 (file)
@@ -8,3 +8,16 @@ define i32 @f1(i32 %a) {
 }
 
 declare i32 @llvm.bswap.i32(i32) nounwind readnone
+
+define i32 @f2(i32 %X) {
+; CHECK: f2:
+; CHECK: revsh r0, r0
+        %tmp1 = lshr i32 %X, 8
+        %tmp1.upgrd.1 = trunc i32 %tmp1 to i16
+        %tmp3 = trunc i32 %X to i16
+        %tmp2 = and i16 %tmp1.upgrd.1, 255
+        %tmp4 = shl i16 %tmp3, 8
+        %tmp5 = or i16 %tmp2, %tmp4
+        %tmp5.upgrd.2 = sext i16 %tmp5 to i32
+        ret i32 %tmp5.upgrd.2
+}