summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-08-05 01:45:17 +0000
committerCraig Topper <craig.topper@intel.com>2017-08-05 01:45:17 +0000
commitfc5283092b3a1e354a9be28ba68437aef7cfb076 (patch)
tree418360d89bc5a8931c6de925b6e35a46afef4812 /llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
parent5fb82efebf66400f40f5e4745f64537ee7a66c74 (diff)
downloadbcm5719-llvm-fc5283092b3a1e354a9be28ba68437aef7cfb076.tar.gz
bcm5719-llvm-fc5283092b3a1e354a9be28ba68437aef7cfb076.zip
[InstCombine] In foldSelectICmpAnd, if we need to to truncate from the 'and' type to the 'select' type, do it after shifting right instead of just bailing.
Previously we were always trying to emit the zext or truncate before any shift. This meant if the 'and' mask was larger than the size of the truncate we would skip the transformation. Now we shift the result of the and right first leaving the bit within the range of the truncate. This matches what we are doing in foldSelectICmpAndOr for the same problem. llvm-svn: 310159
Diffstat (limited to 'llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll')
-rw-r--r--llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll19
1 files changed, 10 insertions, 9 deletions
diff --git a/llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll b/llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
index f562c6ebafb..c92a749f724 100644
--- a/llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
+++ b/llvm/test/Transforms/InstCombine/select-with-bitwise-ops.ll
@@ -256,11 +256,11 @@ define i32 @select_icmp_x_and_2147483648_ne_0_or_2147483648(i32 %x) {
define i32 @test65(i64 %x) {
; CHECK-LABEL: @test65(
-; CHECK-NEXT: [[X_TR:%.*]] = trunc i64 %x to i32
-; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[X_TR]], 3
-; CHECK-NEXT: [[TMP2:%.*]] = and i32 [[TMP1]], 2
-; CHECK-NEXT: [[TMP3:%.*]] = xor i32 [[TMP2]], 42
-; CHECK-NEXT: ret i32 [[TMP3]]
+; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[X:%.*]], 3
+; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP1]] to i32
+; CHECK-NEXT: [[TMP3:%.*]] = and i32 [[TMP2]], 2
+; CHECK-NEXT: [[TMP4:%.*]] = xor i32 [[TMP3]], 42
+; CHECK-NEXT: ret i32 [[TMP4]]
;
%1 = and i64 %x, 16
%2 = icmp ne i64 %1, 0
@@ -270,10 +270,11 @@ define i32 @test65(i64 %x) {
define i32 @test66(i64 %x) {
; CHECK-LABEL: @test66(
-; CHECK-NEXT: [[TMP1:%.*]] = and i64 %x, 4294967296
-; CHECK-NEXT: [[TMP2:%.*]] = icmp eq i64 [[TMP1]], 0
-; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], i32 42, i32 40
-; CHECK-NEXT: ret i32 [[TMP3]]
+; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[X:%.*]], 31
+; CHECK-NEXT: [[TMP2:%.*]] = trunc i64 [[TMP1]] to i32
+; CHECK-NEXT: [[TMP3:%.*]] = and i32 [[TMP2]], 2
+; CHECK-NEXT: [[TMP4:%.*]] = xor i32 [[TMP3]], 42
+; CHECK-NEXT: ret i32 [[TMP4]]
;
%1 = and i64 %x, 4294967296
%2 = icmp ne i64 %1, 0
OpenPOWER on IntegriCloud