diff options
author | Sanjay Patel <spatel@rotateright.com> | 2020-07-04 11:09:14 -0400 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2020-07-04 11:16:23 -0400 |
commit | 3b8ae1001f678be00507f15df0ffaccafec1dae9 (patch) | |
tree | 0a0eb1f8fd627deec297265f9a297bf4b0598cae | |
parent | c3b8bd1eea5b74b6cd4a89f3c221bc2dfa891248 (diff) | |
download | llvm-3b8ae1001f678be00507f15df0ffaccafec1dae9.zip llvm-3b8ae1001f678be00507f15df0ffaccafec1dae9.tar.gz llvm-3b8ae1001f678be00507f15df0ffaccafec1dae9.tar.bz2 |
[InstCombine] fix miscompile from umul_with_overflow matching
As noted in PR46561:
https://bugs.llvm.org/show_bug.cgi?id=46561
...it takes something beyond a minimal IR example to trigger
this bug because it relies on matching non-canonical IR.
There are no tests that show the need for matching this
pattern, so I'm just deleting it to fix the miscompile.
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 11 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/icmp-mul-zext.ll | 8 |
2 files changed, 6 insertions, 13 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index 31cd8e4..f1233b6 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -4646,17 +4646,6 @@ static Instruction *processUMulZExtIdiom(ICmpInst &I, Value *MulVal, case ICmpInst::ICMP_NE: // Recognize pattern: // mulval = mul(zext A, zext B) - // cmp eq/neq mulval, zext trunc mulval - if (ZExtInst *Zext = dyn_cast<ZExtInst>(OtherVal)) - if (Zext->hasOneUse()) { - Value *ZextArg = Zext->getOperand(0); - if (TruncInst *Trunc = dyn_cast<TruncInst>(ZextArg)) - if (Trunc->getType()->getPrimitiveSizeInBits() == MulWidth) - break; //Recognized - } - - // Recognize pattern: - // mulval = mul(zext A, zext B) // cmp eq/neq mulval, and(mulval, mask), mask selects low MulWidth bits. ConstantInt *CI; Value *ValToMask; diff --git a/llvm/test/Transforms/InstCombine/icmp-mul-zext.ll b/llvm/test/Transforms/InstCombine/icmp-mul-zext.ll index 31540e6..9b4d994 100644 --- a/llvm/test/Transforms/InstCombine/icmp-mul-zext.ll +++ b/llvm/test/Transforms/InstCombine/icmp-mul-zext.ll @@ -121,16 +121,20 @@ ret2: ret i16 %trunc_unnecessary ; crash visiting this use after corrupting iterator } -; FIXME: This miscompiles because of broken pattern matching. +; This miscompiled because of broken pattern matching. define i1 @PR46561(i1 %a, i1 %x, i1 %y, i8 %z) { ; CHECK-LABEL: @PR46561( ; CHECK-NEXT: entry: ; CHECK-NEXT: br i1 [[A:%.*]], label [[COND_TRUE:%.*]], label [[END:%.*]] ; CHECK: cond.true: +; CHECK-NEXT: [[MULBOOL:%.*]] = and i1 [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[TMP0:%.*]] = and i8 [[Z:%.*]], 1 +; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i8 [[TMP0]], 0 +; CHECK-NEXT: [[PHI_CMP:%.*]] = xor i1 [[TMP1]], [[MULBOOL]] ; CHECK-NEXT: br label [[END]] ; CHECK: end: -; CHECK-NEXT: [[P:%.*]] = phi i1 [ true, [[COND_TRUE]] ], [ false, [[ENTRY:%.*]] ] +; CHECK-NEXT: [[P:%.*]] = phi i1 [ [[PHI_CMP]], [[COND_TRUE]] ], [ false, [[ENTRY:%.*]] ] ; CHECK-NEXT: ret i1 [[P]] ; entry: |