[PowerPC] Use rldicr instruction for AND with an immediate if possible
Emit clrrdi (extended mnemonic for rldicr) for AND-ing with masks that
clear bits from the right hand size.
Committing on behalf of Hiroshi Inoue.
Differential Revision: https://reviews.llvm.org/D29388
llvm-svn: 296143
diff --git a/llvm/test/CodeGen/PowerPC/srl-mask.ll b/llvm/test/CodeGen/PowerPC/srl-mask.ll
index e581eae..1a429b1 100644
--- a/llvm/test/CodeGen/PowerPC/srl-mask.ll
+++ b/llvm/test/CodeGen/PowerPC/srl-mask.ll
@@ -12,5 +12,16 @@
; CHECK: blr
}
+; for AND with an immediate like (x & ~0xFFFF)
+; we should use rldicl instruction
+define i64 @bar(i64 %x) #0 {
+entry:
+; CHECK-LABEL: @bar
+ %a = and i64 %x, 18446744073709486080
+; CHECK: rldicr 3, 3, 0, 47
+ ret i64 %a
+; CHECK: blr
+}
+
attributes #0 = { nounwind }