<div dir="ltr">Oops. The code I modified would NOT be called from clang's CodeGen path.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Fri, Mar 24, 2017 at 3:34 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That seems highly unlikely to be related. The code I modified would be called from clangs CodeGen path not from anything in Sema.</div><div class="gmail_extra"><span class="HOEnZb"><font color="#888888"><br clear="all"><div><div class="m_-8033891758280088760gmail_signature" data-smartmail="gmail_signature">~Craig</div></div></font></span><div><div class="h5">
<br><div class="gmail_quote">On Fri, Mar 24, 2017 at 3:28 PM, Vitaly Buka <span dir="ltr"><<a href="mailto:vitalybuka@google.com" target="_blank">vitalybuka@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks for revert.</div>Not sure, but this may be related as well<div><br></div><div><div><a href="http://lab.llvm.org:8011/builders/sanitizer-ppc64le-linux/builds/1847/steps/bootstrap%20clang/logs/stdio" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/sanitizer-ppc64le-linux/<wbr>builds/1847/steps/bootstrap%<wbr>20clang/logs/stdio</a><br></div><div><br></div><div><pre style="font-family:"courier new",courier,monotype,monospace;font-size:medium"><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout">[100%] Cleaning compiler-rt...
[100%] Building CXX object tools/llvm-objdump/CMakeFiles/<wbr>llvm-objdump.dir/COFFDump.cpp.<wbr>o
[100%] Linking CXX executable ../../bin/sancov
[100%] Performing build step for 'compiler-rt'
Scanning dependencies of target RTSanitizerCommonLibc.powerpc6<wbr>4le
[  1%] Building CXX object lib/sanitizer_common/CMakeFile<wbr>s/RTSanitizerCommonLibc.powerp<wbr>c64le.dir/sanitizer_common_<wbr>libcdep.cc.o
#0 0x0000000011bd5410 PrintStackTrace /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/lib/Support/Unix/Signals.<wbr>inc:402:13
#1 0x0000000011bd5410 PrintStackTraceSignalHandler(v<wbr>oid*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/lib/Support/Unix/Signals.<wbr>inc:465:0
#2 0x0000000011bd5864 RunSignalHandlers /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/lib/Support/Signals.cpp:<wbr>45:5
#3 0x0000000011bd5864 SignalHandler(int) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/lib/Support/Unix/Signals.<wbr>inc:246:0
#4 0x00003fff8e2c0478  0x478 getPointer
#5 0x00003fff8e2c0478 /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/include/llvm/ADT/PointerI<wbr>ntPair.h:56:58 getPrefix
#6 0x00003fff8e2c0478 /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/include/<wbr>clang/AST/NestedNameSpecifier.<wbr>h:162:0 getPrefix
#7 0x00003fff8e2c0478 /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/include/<wbr>clang/AST/NestedNameSpecifier.<wbr>h:314:0 clang::NestedNameSpecifierLoc:<wbr>:getSourceRange() const
#8 0x00003fff8e2c0478 /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/AST/<wbr>NestedNameSpecifier.cpp:400:0 
#9 0x00003fff8e2c0478 getBeginLoc /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/include/<wbr>clang/AST/NestedNameSpecifier.<wbr>h:283:12
#10 0x00003fff8e2c0478 clang::MemberExpr::getLocStart<wbr>() const /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/AST/Expr.<wbr>cpp:1500:0
#11 0x0000000013ac4ba0 getSourceRangeImpl<clang::Memb<wbr>erExpr> /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/AST/Stmt.<wbr>cpp:240:53
#12 0x0000000013ac4ba0 clang::Stmt::getSourceRange() const /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm_build64/tools/clang/<wbr>include/clang/AST/StmtNodes.<wbr>inc:597:0
#13 0x0000010004c4acb8
#14 0x0000000013a0d79c clang::TreeTransform<(anonymou<wbr>s namespace)::TemplateInstantiat<wbr>or>::TransformCallExpr(clang::<wbr>CallExpr*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/<wbr>TreeTransform.h:9041:31
#15 0x0000000013aee72c clang::TreeTransform<(anonymou<wbr>s namespace)::TemplateInstantiat<wbr>or>::TransformExpr(clang::<wbr>Expr*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm_build64/tools/clang/<wbr>include/clang/AST/StmtNodes.<wbr>inc:329:1
#16 0x000000001341d658 clang::TreeTransform<(anonymou<wbr>s namespace)::TemplateInstantiat<wbr>or>::TransformStmt(clang::<wbr>Stmt*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/<wbr>TreeTransform.h:3242:35
#17 0x0000000013413488 clang::TreeTransform<(anonymou<wbr>s namespace)::TemplateInstantiat<wbr>or>::TransformCompoundStmt(<wbr>clang::CompoundStmt*, bool) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/<wbr>TreeTransform.h:6355:38
#18 0x0000000013412b4c clang::TreeTransform<(anonymou<wbr>s namespace)::TemplateInstantiat<wbr>or>::TransformCompoundStmt(<wbr>clang::CompoundStmt*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/<wbr>TreeTransform.h:6342:23
#19 0x000000001342dab0 clang::TreeTransform<(anonymou<wbr>s namespace)::TemplateInstantiat<wbr>or>::TransformStmt(clang::<wbr>Stmt*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm_build64/tools/clang/<wbr>include/clang/AST/StmtNodes.<wbr>inc:79:1
#20 0x0000000013432d5c clang::Sema::SubstStmt(clang::<wbr>Stmt*, clang::MultiLevelTemplateArgum<wbr>entList const&) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/<wbr>SemaTemplateInstantiate.cpp:<wbr>2733:23
#21 0x0000000013412e3c clang::Sema::InstantiateFuncti<wbr>onDefinition(clang::<wbr>SourceLocation, clang::FunctionDecl*, bool, bool, bool) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/Sema<wbr>TemplateInstantiateDecl.cpp:<wbr>3887:23
#22 0x0000000013412a98 clang::Sema::PerformPendingIns<wbr>tantiations(bool) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/Sema<wbr>TemplateInstantiateDecl.cpp:<wbr>5131:7
#23 0x0000000013453ebc clang::Sema::ActOnEndOfTransla<wbr>tionUnit() /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Sema/<wbr>Sema.cpp:725:5
#24 0x000000001344b71c clang::Parser::ParseTopLevelDe<wbr>cl(clang::OpaquePtr<clang::<wbr>DeclGroupRef>&) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Parse/<wbr>Parser.cpp:618:15
#25 0x0000000012e0c184 clang::ParseAST(clang::Sema&, bool, bool) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Parse/<wbr>ParseAST.cpp:147:18
#26 0x0000000012b3bd38 clang::ASTFrontendAction::Exec<wbr>uteAction() /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Frontend/<wbr>FrontendAction.cpp:611:3
#27 0x0000000012b3589c clang::CodeGenAction::ExecuteA<wbr>ction() /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/CodeGen/<wbr>CodeGenAction.cpp:989:28
#28 0x0000000012222a84 clang::FrontendAction::Execute<wbr>() /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Frontend/<wbr>FrontendAction.cpp:512:8
#29 0x00000000125e1118 clang::CompilerInstance::Execu<wbr>teAction(clang::FrontendAction<wbr>&) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/Frontend/<wbr>CompilerInstance.cpp:959:11
#30 0x00000000122220c4 clang::ExecuteCompilerInvocati<wbr>on(clang::CompilerInstance*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/lib/FrontendT<wbr>ool/ExecuteCompilerInvocation.<wbr>cpp:249:25
#31 0x00000000121dc6a8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/tools/driver/<wbr>cc1_main.cpp:221:13
#32 0x00000000122cd724 ExecuteCC1Tool /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/tools/driver/<wbr>driver.cpp:299:12
#33 0x00000000122cd724 main /home/buildbots/ppc64le-saniti<wbr>zer/sanitizer-ppc64le/build/<wbr>llvm/tools/clang/tools/driver/<wbr>driver.cpp:380:0
#34 0x000000001042ed64 generic_start_main.isra.0 (/home/buildbots/ppc64le-sanit<wbr>izer/sanitizer-ppc64le/build/<wbr>llvm_build64/bin/clang-5.0+<wbr>0x1042ed64)
#35 0x000000001042bdc4 __libc_start_main (/home/buildbots/ppc64le-sanit<wbr>izer/sanitizer-ppc64le/build</span></pre></div></div></div><div class="m_-8033891758280088760HOEnZb"><div class="m_-8033891758280088760h5"><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 24, 2017 at 3:04 PM Vitaly Buka <<a href="mailto:vitalybuka@google.com" target="_blank">vitalybuka@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">These tests are broken after the patch <div><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/6467/steps/test%20tsan%20in%20debug%20compiler-rt%20build/logs/stdio" target="_blank">http://lab.llvm.org:8011/build<wbr>ers/sanitizer-x86_64-linux-<wbr>autoconf/builds/6467/steps/<wbr>test%20tsan%20in%20debug%<wbr>20compiler-rt%20build/logs/<wbr>stdio</a><br></div><div><br></div><div><pre style="font-family:"courier new",courier,monotype,monospace;font-size:medium"><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout">Scanning dependencies of target TsanUnitTests
[ 90%] Built target TsanUnitTests
[ 90%] Built target SanitizerLintCheck
-- libcxx_tsan_x86_64 configure command succeeded.  See also /mnt/b/sanitizer-buildbot4/san<wbr>itizer-x86_64-linux-autoconf/<wbr>build/tsan_debug_build/tools/<wbr>clang/runtime/compiler-rt-<wbr>bins/lib/tsan/libcxx_tsan_x86_<wbr>64/src/libcxx_tsan_x86_64-<wbr>stamp/libcxx_tsan_x86_64-<wbr>configure-*.log
[ 90</span><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout">%] Performing build step for 'libcxx_tsan_x86_64'
</span><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout">make[7]: *** [lib/tsan/CMakeFiles/GotsanRun<wbr>timeCheck] Error 139
make[6]: *** [lib/tsan/CMakeFiles/GotsanRun<wbr>timeCheck.dir/all] Error 2
make[6]: *** Waiting for unfinished jobs....
-- libcxx_tsan_x86_64 build command succeeded.  See also /mnt/b/sanitizer-buildbot4/san<wbr>itizer-x86_64-linux-autoconf/<wbr>build/tsan_debug_build/tools/<wbr>clang/runtime/compiler-rt-<wbr>bins/lib/tsan/libcxx_tsan_x86_<wbr>64/src/libcxx_tsan_x86_64-<wbr>stamp/libcxx_tsan_x86_64-<wbr>build-*.log
[ 90%] Performing install step for 'libcxx_tsan_x86_64'
-- libcxx_tsan_x86_64 install command succeeded.  See also /mnt/b/sanitizer-buildbot4/san<wbr>itizer-x86_64-linux-autoconf/<wbr>build/tsan_debug_build/tools/<wbr>clang/runtime/compiler-rt-<wbr>bins/lib/tsan/libcxx_tsan_x86_<wbr>64/src/libcxx_tsan_x86_64-<wbr>stamp/libcxx_tsan_x86_64-<wbr>install-*.log
[ 95%] Completed 'libcxx_tsan_x86_64'
[ 95%] Built target libcxx_tsan_x86_64
make[5]: *** [test/tsan/CMakeFiles/check-ts<wbr>an.dir/rule] Error 2
make[4]: *** [check-tsan] Error 2
make[3]: *** [tools/clang/runtime/CMakeFile<wbr>s/check-tsan] Error 2
make[2]: *** [tools/clang/runtime/CMakeFile<wbr>s/check-tsan.dir/all] Error 2
make[1]: *** [tools/clang/runtime/CMakeFile<wbr>s/check-tsan.dir/rule] Error 2
make: *** [check-tsan] Error 2
+ echo @@@STEP_FAILURE@@@
@@@STEP_FAILURE@@@</span></pre><pre style="font-family:"courier new",courier,monotype,monospace;font-size:medium"><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout"><br></span></pre><pre style="font-family:"courier new",courier,monotype,monospace;font-size:medium"><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout">Reproducible locally with</span></pre><pre style="font-family:"courier new",courier,monotype,monospace;font-size:medium"><span class="m_-8033891758280088760m_-1091741227529772503inbox-inbox-stdout">MAKE_JOBS=30 BUILDBOT_REVISION=298711 BUILDBOT_CLOBBER= llvm/projects/zorg/zorg/buildb<wbr>ot/builders/sanitizers/buildbo<wbr>t_standard.sh</span></pre></div></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 24, 2017 at 10:09 AM Craig Topper via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
Date: Fri Mar 24 11:56:51 2017<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
New Revision: 298711<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=298711&view=rev" rel="noreferrer" class="m_-8033891758280088760m_-1091741227529772503gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=298711&view=rev</a><br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
Log:<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
[InstCombine] Provide a way to calculate KnownZero/One for Add/Sub in SimplifyDemandedUseBits without recursing into ComputeKnownBits<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
SimplifyDemandedUseBits for Add/Sub already recursed down LHS and RHS for simplifying bits. If that didn't provide any simplifications we fall back to calling computeKnownBits which will recurse again. Instead just take the known bits for LHS and RHS we already have and call into a new function in ValueTracking that can calculate the known bits given the LHS/RHS bits.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
Modified:<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
    llvm/trunk/include/llvm/Analys<wbr>is/ValueTracking.h<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
    llvm/trunk/lib/Analysis/ValueT<wbr>racking.cpp<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
    llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineSimplifyDem<wbr>anded.cpp<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
Modified: llvm/trunk/include/llvm/Analys<wbr>is/ValueTracking.h<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ValueTracking.h?rev=298711&r1=298710&r2=298711&view=diff" rel="noreferrer" class="m_-8033891758280088760m_-1091741227529772503gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/include/llvm/<wbr>Analysis/ValueTracking.h?rev=<wbr>298711&r1=298710&r2=298711&<wbr>view=diff</a><br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
==============================<wbr>==============================<wbr>==================<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
--- llvm/trunk/include/llvm/Analys<wbr>is/ValueTracking.h (original)<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+++ llvm/trunk/include/llvm/Analys<wbr>is/ValueTracking.h Fri Mar 24 11:56:51 2017<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
@@ -55,6 +55,11 @@ template <typename T> class ArrayRef;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
                         const Instruction *CxtI = nullptr,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
                         const DominatorTree *DT = nullptr,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
                         OptimizationRemarkEmitter *ORE = nullptr);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  /// Compute known bits for add/sub using LHS/RHS known bits.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  void computeKnownBitsForAddSub(bool Add, bool NSW,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                 APInt &KnownZero, APInt &KnownOne,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                 APInt &LHSKnownZero, APInt &LHSKnownOne,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                 APInt &RHSKnownZero, APInt &RHSKnownOne);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   /// Compute known bits from the range metadata.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   /// \p KnownZero the set of bits that are known to be zero<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   /// \p KnownOne the set of bits that are known to be one<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
Modified: llvm/trunk/lib/Analysis/ValueT<wbr>racking.cpp<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=298711&r1=298710&r2=298711&view=diff" rel="noreferrer" class="m_-8033891758280088760m_-1091741227529772503gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Analysis/<wbr>ValueTracking.cpp?rev=298711&<wbr>r1=298710&r2=298711&view=diff</a><br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
==============================<wbr>==============================<wbr>==================<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
--- llvm/trunk/lib/Analysis/ValueT<wbr>racking.cpp (original)<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+++ llvm/trunk/lib/Analysis/ValueT<wbr>racking.cpp Fri Mar 24 11:56:51 2017<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
@@ -250,37 +250,29 @@ unsigned llvm::ComputeNumSignBits(const<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   return ::ComputeNumSignBits(V, Depth, Query(DL, AC, safeCxtI(V, CxtI), DT));<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
 }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-static void computeKnownBitsAddSub(bool Add, const Value *Op0, const Value *Op1,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-                                   bool NSW,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-                                   APInt &KnownZero, APInt &KnownOne,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-                                   APInt &KnownZero2, APInt &KnownOne2,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-                                   unsigned Depth, const Query &Q) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  unsigned BitWidth = KnownZero.getBitWidth();<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  // If an initial sequence of bits in the result is not needed, the<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  // corresponding bits in the operands are not needed.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  APInt LHSKnownZero(BitWidth, 0), LHSKnownOne(BitWidth, 0);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  computeKnownBits(Op0, LHSKnownZero, LHSKnownOne, Depth + 1, Q);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  computeKnownBits(Op1, KnownZero2, KnownOne2, Depth + 1, Q);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+/// Compute known bits for add/sub using LHS/RHS known bits.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+void llvm::computeKnownBitsForAddSu<wbr>b(bool Add, bool NSW,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                     APInt &KnownZero, APInt &KnownOne,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                     APInt &LHSKnownZero, APInt &LHSKnownOne,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                     APInt &RHSKnownZero, APInt &RHSKnownOne) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   // Carry in a 1 for a subtract, rather than a 0.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   uint64_t CarryIn = 0;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   if (!Add) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
     // Sum = LHS + ~RHS + 1<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-    std::swap(KnownZero2, KnownOne2);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+    std::swap(RHSKnownZero, RHSKnownOne);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
     CarryIn = 1;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  APInt PossibleSumZero = ~LHSKnownZero + ~KnownZero2 + CarryIn;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  APInt PossibleSumOne = LHSKnownOne + KnownOne2 + CarryIn;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  APInt PossibleSumZero = ~LHSKnownZero + ~RHSKnownZero + CarryIn;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  APInt PossibleSumOne = LHSKnownOne + RHSKnownOne + CarryIn;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   // Compute known bits of the carry.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  APInt CarryKnownZero = ~(PossibleSumZero ^ LHSKnownZero ^ KnownZero2);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  APInt CarryKnownOne = PossibleSumOne ^ LHSKnownOne ^ KnownOne2;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  APInt CarryKnownZero = ~(PossibleSumZero ^ LHSKnownZero ^ RHSKnownZero);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  APInt CarryKnownOne = PossibleSumOne ^ LHSKnownOne ^ RHSKnownOne;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   // Compute set of known bits (where all three relevant bits are known).<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   APInt LHSKnown = LHSKnownZero | LHSKnownOne;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-  APInt RHSKnown = KnownZero2 | KnownOne2;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  APInt RHSKnown = RHSKnownZero | RHSKnownOne;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   APInt CarryKnown = CarryKnownZero | CarryKnownOne;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   APInt Known = LHSKnown & RHSKnown & CarryKnown;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
@@ -296,14 +288,36 @@ static void computeKnownBitsAddSub(bool<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
     if (NSW) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
       // Adding two non-negative numbers, or subtracting a negative number from<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
       // a non-negative one, can't wrap into negative.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-      if (LHSKnownZero.isNegative() && KnownZero2.isNegative())<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+      if (LHSKnownZero.isNegative() && RHSKnownZero.isNegative())<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
         KnownZero.setSignBit();<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
       // Adding two negative numbers, or subtracting a non-negative number from<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
       // a negative one, can't wrap into non-negative.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-      else if (LHSKnownOne.isNegative() && KnownOne2.isNegative())<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+      else if (LHSKnownOne.isNegative() && RHSKnownOne.isNegative())<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
         KnownOne.setSignBit();<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
     }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  // Put the RHS/LHS back how we found them.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  if (!Add) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+    std::swap(RHSKnownZero, RHSKnownOne);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+}<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+static void computeKnownBitsAddSub(bool Add, const Value *Op0, const Value *Op1,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                   bool NSW,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                   APInt &KnownZero, APInt &KnownOne,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                   APInt &KnownZero2, APInt &KnownOne2,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                                   unsigned Depth, const Query &Q) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  unsigned BitWidth = KnownZero.getBitWidth();<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  // If an initial sequence of bits in the result is not needed, the<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  // corresponding bits in the operands are not needed.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  APInt LHSKnownZero(BitWidth, 0), LHSKnownOne(BitWidth, 0);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  computeKnownBits(Op0, LHSKnownZero, LHSKnownOne, Depth + 1, Q);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  computeKnownBits(Op1, KnownZero2, KnownOne2, Depth + 1, Q);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+  computeKnownBitsForAddSub(Add, NSW, KnownZero, KnownOne, LHSKnownZero,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                            LHSKnownOne, KnownZero2, KnownOne2);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
 }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
 static void computeKnownBitsMul(const Value *Op0, const Value *Op1, bool NSW,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
Modified: llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineSimplifyDem<wbr>anded.cpp<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp?rev=298711&r1=298710&r2=298711&view=diff" rel="noreferrer" class="m_-8033891758280088760m_-1091741227529772503gmail_msg" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/llvm/trunk/lib/Transform<wbr>s/InstCombine/InstCombineSimpl<wbr>ifyDemanded.cpp?rev=298711&r1=<wbr>298710&r2=298711&view=diff</a><br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
==============================<wbr>==============================<wbr>==================<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
--- llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineSimplifyDem<wbr>anded.cpp (original)<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+++ llvm/trunk/lib/Transforms/Inst<wbr>Combine/InstCombineSimplifyDem<wbr>anded.cpp Fri Mar 24 11:56:51 2017<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
@@ -538,7 +538,7 @@ Value *InstCombiner::SimplifyDemande<wbr>dUse<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
                                LHSKnownZero, LHSKnownOne, Depth + 1) ||<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
           ShrinkDemandedConstant(I, 1, DemandedFromOps) ||<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
           SimplifyDemandedBits(I->getOp<wbr>erandUse(1), DemandedFromOps,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-                               LHSKnownZero, LHSKnownOne, Depth + 1)) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                               RHSKnownZero, RHSKnownOne, Depth + 1)) {<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
         // Disable the nsw and nuw flags here: We can no longer guarantee that<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
         // we won't wrap after simplification. Removing the nsw/nuw flags is<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
         // legal here because the top bit is not demanded.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
@@ -549,9 +549,10 @@ Value *InstCombiner::SimplifyDemande<wbr>dUse<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
       }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
     }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-    // Otherwise just hand the add/sub off to computeKnownBits to fill in<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-    // the known zeros and ones.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
-    computeKnownBits(V, KnownZero, KnownOne, Depth, CxtI);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+    // Otherwise compute the known bits using the RHS/LHS known bits.<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+    bool NSW = cast<OverflowingBinaryOperator<wbr>>(I)->hasNoSignedWrap();<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+    computeKnownBitsForAddSub(V, NSW, KnownZero, KnownOne, LHSKnownZero,<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
+                              LHSKnownOne, RHSKnownZero, RHSKnownOne);<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
     break;<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   }<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
   case Instruction::Shl:<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
______________________________<wbr>_________________<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
llvm-commits mailing list<br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<a href="mailto:llvm-commits@lists.llvm.org" class="m_-8033891758280088760m_-1091741227529772503gmail_msg" target="_blank">llvm-commits@lists.llvm.org</a><br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" class="m_-8033891758280088760m_-1091741227529772503gmail_msg" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br class="m_-8033891758280088760m_-1091741227529772503gmail_msg">
</blockquote></div></blockquote></div>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>