From: David Majnemer Date: Sat, 11 Oct 2014 10:19:52 +0000 (+0000) Subject: InstCombine: mul to shl shouldn't preserve nsw X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2af441e26e010e6c4b935d94f03fc8487e75f4b4;p=oota-llvm.git InstCombine: mul to shl shouldn't preserve nsw consider: mul i32 nsw %x, -2147483648 this instruction will not result in poison if %x is 1 however, if we transform this into: shl i32 nsw %x, 31 then we will be generating poison because we just shifted into the sign bit. This fixes PR21242. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219566 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 260b7e7e4fe..249456fa6ea 100644 --- a/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -176,8 +176,6 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { if (NewCst) { BinaryOperator *Shl = BinaryOperator::CreateShl(NewOp, NewCst); - if (I.hasNoSignedWrap()) - Shl->setHasNoSignedWrap(); if (I.hasNoUnsignedWrap()) Shl->setHasNoUnsignedWrap(); diff --git a/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll b/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll index a75a4656e68..895b2603ad9 100644 --- a/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll +++ b/test/Transforms/InstCombine/2011-06-13-nsw-alloca.ll @@ -15,7 +15,7 @@ define void @fu1(i32 %parm) nounwind ssp { ;