llvm.org GIT mirror llvm / a3ee448
Merging r348181: ------------------------------------------------------------------------ r348181 | lebedevri | 2018-12-03 12:07:58 -0800 (Mon, 03 Dec 2018) | 8 lines [InstCombine] foldICmpWithLowBitMaskedVal(): disable 2 faulty folds. These two folds are invalid for this non-constant pattern when the mask ends up being all-ones: https://rise4fun.com/Alive/9au https://rise4fun.com/Alive/UcQM Fixes https://bugs.llvm.org/show_bug.cgi?id=39861 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_70@348528 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 1 year, 10 months ago
3 changed file(s) with 16 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
29232923 // x & (-1 >> y) s>= x -> x s<= (-1 >> y)
29242924 if (X != I.getOperand(1)) // X must be on RHS of comparison!
29252925 return nullptr; // Ignore the other case.
2926 if (!match(M, m_Constant())) // Can not do this fold with non-constant.
2927 return nullptr;
29262928 DstPred = ICmpInst::Predicate::ICMP_SLE;
29272929 break;
29282930 case ICmpInst::Predicate::ICMP_SLT:
29292931 // x & (-1 >> y) s< x -> x s> (-1 >> y)
29302932 if (X != I.getOperand(1)) // X must be on RHS of comparison!
29312933 return nullptr; // Ignore the other case.
2934 if (!match(M, m_Constant())) // Can not do this fold with non-constant.
2935 return nullptr;
29322936 DstPred = ICmpInst::Predicate::ICMP_SGT;
29332937 break;
29342938 case ICmpInst::Predicate::ICMP_SLE:
2525 define i1 @pv(i8 %x, i8 %y) {
2626 ; CHECK-LABEL: @pv(
2727 ; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
28 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sge i8 [[TMP0]], [[X:%.*]]
29 ; CHECK-NEXT: ret i1 [[TMP1]]
28 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[TMP0]], [[X:%.*]]
29 ; CHECK-NEXT: [[RET:%.*]] = icmp sge i8 [[TMP1]], [[X]]
30 ; CHECK-NEXT: ret i1 [[RET]]
3031 ;
3132 %tmp0 = lshr i8 -1, %y
3233 %tmp1 = and i8 %tmp0, %x
119120 ; CHECK-LABEL: @cv0(
120121 ; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
121122 ; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
122 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sle i8 [[X]], [[TMP0]]
123 ; CHECK-NEXT: ret i1 [[TMP1]]
123 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X]], [[TMP0]]
124 ; CHECK-NEXT: [[RET:%.*]] = icmp sge i8 [[TMP1]], [[X]]
125 ; CHECK-NEXT: ret i1 [[RET]]
124126 ;
125127 %x = call i8 @gen8()
126128 %tmp0 = lshr i8 -1, %y
2525 define i1 @pv(i8 %x, i8 %y) {
2626 ; CHECK-LABEL: @pv(
2727 ; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
28 ; CHECK-NEXT: [[TMP1:%.*]] = icmp slt i8 [[TMP0]], [[X:%.*]]
29 ; CHECK-NEXT: ret i1 [[TMP1]]
28 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[TMP0]], [[X:%.*]]
29 ; CHECK-NEXT: [[RET:%.*]] = icmp slt i8 [[TMP1]], [[X]]
30 ; CHECK-NEXT: ret i1 [[RET]]
3031 ;
3132 %tmp0 = lshr i8 -1, %y
3233 %tmp1 = and i8 %tmp0, %x
119120 ; CHECK-LABEL: @cv0(
120121 ; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
121122 ; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
122 ; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i8 [[X]], [[TMP0]]
123 ; CHECK-NEXT: ret i1 [[TMP1]]
123 ; CHECK-NEXT: [[TMP1:%.*]] = and i8 [[X]], [[TMP0]]
124 ; CHECK-NEXT: [[RET:%.*]] = icmp slt i8 [[TMP1]], [[X]]
125 ; CHECK-NEXT: ret i1 [[RET]]
124126 ;
125127 %x = call i8 @gen8()
126128 %tmp0 = lshr i8 -1, %y