Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

At least one condition is wrong (same conditional expr of if/else if) (llvm/lib/CodeGen/GlobalISel.cpp:1614 <=> 1617) #45851

Closed Quuxplusone closed 4 years ago

Quuxplusone commented 4 years ago
Bugzilla Link PR46882
Status RESOLVED FIXED
Importance P normal
Reported by Ustchcs_Bugfinder (info@ustchcs.com)
Reported on 2020-07-28 23:15:13 -0700
Last modified on 2020-07-29 10:43:15 -0700
Version trunk
Hardware All All
CC david.bolvansky@gmail.com, llvm-bugs@lists.llvm.org, Matthew.Arsenault@amd.com, quentin.colombet@gmail.com
Fixed by commit(s)
Attachments 1590559842.jpg (150612 bytes, image/jpeg)
1590559842.png (150612 bytes, image/png)
Blocks
Blocked by
See also
Created attachment 23784
tool-report-screenshot

The use of if (Condition) {...} else if (Condition) {...} pattern should be
avoided.

(commit:23d6525cbdc9de7cbfe7640d1e9e4f25a0c5dd85)

llvm/lib/CodeGen/GlobalISel.cpp:

  1574  LegalizerHelper::LegalizeResult
  1575  LegalizerHelper::widenScalarExtract(MachineInstr &MI, unsigned TypeIdx,
  1576                                      LLT WideTy) {
  ...
  1612      // Do a shift in the source type.
  1613      LLT ShiftTy = SrcTy;
  1614      if (WideTy.getSizeInBits() > SrcTy.getSizeInBits()) {
  1615        Src = MIRBuilder.buildAnyExt(WideTy, Src);
  1616        ShiftTy = WideTy;
  1617      } else if (WideTy.getSizeInBits() > SrcTy.getSizeInBits())
  1618        return UnableToLegalize;
  1619
  1620      auto LShr = MIRBuilder.buildLShr(
  1621        ShiftTy, Src, MIRBuilder.buildConstant(ShiftTy, Offset));
  1622      MIRBuilder.buildTrunc(DstReg, LShr);
  1623      MI.eraseFromParent();
  1624      return Legalized;
  1625    }
  ...
  1651  }

Reported by: Ustchcs Toolsets Bugfinder
(bugfinder-2.2: The use of if (Condition) {...} else if (Condition) {...}
pattern should be avoided.)
Quuxplusone commented 4 years ago

Attached 1590559842.jpg (150612 bytes, image/jpeg): tool-report-screenshot

Quuxplusone commented 4 years ago

Attached 1590559842.png (150612 bytes, image/png): tool report screenshot

Quuxplusone commented 4 years ago

Fixed in 90b76dac57861e438880a260834afb193e603c5a