[PATCH] D149033: [NFC]Fix 2 logic dead code

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 2 00:03:11 PDT 2023


craig.topper added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:5452
       // Get the exponent as a positive value.
       if ((int)Val < 0)
         Val = -Val;
----------------
XinWang10 wrote:
> skan wrote:
> > Shouldn't we remove the cast too?
> Sure, it should be.
What was wrong with the original code? The if wasn't meaningless, the cast made it a signed comparison. The unsigned type prevented the undefined behavior on Val = -Val.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149033/new/

https://reviews.llvm.org/D149033



More information about the llvm-commits mailing list