[PATCH] D136753: [DemandedBits] Add Div instruction to DetermineLiveOperandBits

Zain Jaffal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 02:59:21 PDT 2022


zjaffal created this revision.
zjaffal added reviewers: t.p.northover, RKSimon, lebedev.ri.
Herald added a subscriber: hiraditya.
Herald added a project: All.
zjaffal published this revision for review.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

DetermineLiveOperandBits is missing a case for `div` instructions. Before the patch, the pass assumed that the operand of div instructions uses all the available bits which can be an overestimate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136753

Files:
  llvm/lib/Analysis/DemandedBits.cpp
  llvm/test/Transforms/PhaseOrdering/ARM/arm_mean_q7.ll


Index: llvm/test/Transforms/PhaseOrdering/ARM/arm_mean_q7.ll
===================================================================
--- llvm/test/Transforms/PhaseOrdering/ARM/arm_mean_q7.ll
+++ llvm/test/Transforms/PhaseOrdering/ARM/arm_mean_q7.ll
@@ -38,7 +38,7 @@
 ; CHECK:       vector.body:
 ; CHECK-NEXT:    [[ACTIVE_LANE_MASK:%.*]] = tail call <16 x i1> @llvm.get.active.lane.mask.v16i1.i32(i32 0, i32 [[AND]])
 ; CHECK-NEXT:    [[WIDE_MASKED_LOAD:%.*]] = tail call <16 x i8> @llvm.masked.load.v16i8.p0(ptr [[PSRC_ADDR_0_LCSSA]], i32 1, <16 x i1> [[ACTIVE_LANE_MASK]], <16 x i8> poison)
-; CHECK-NEXT:    [[TMP4:%.*]] = sext <16 x i8> [[WIDE_MASKED_LOAD]] to <16 x i32>
+; CHECK-NEXT:    [[TMP4:%.*]] = zext <16 x i8> [[WIDE_MASKED_LOAD]] to <16 x i32>
 ; CHECK-NEXT:    [[TMP5:%.*]] = select <16 x i1> [[ACTIVE_LANE_MASK]], <16 x i32> [[TMP4]], <16 x i32> zeroinitializer
 ; CHECK-NEXT:    [[TMP6:%.*]] = tail call i32 @llvm.vector.reduce.add.v16i32(<16 x i32> [[TMP5]])
 ; CHECK-NEXT:    [[TMP7:%.*]] = add i32 [[TMP6]], [[SUM_0_LCSSA]]
Index: llvm/lib/Analysis/DemandedBits.cpp
===================================================================
--- llvm/lib/Analysis/DemandedBits.cpp
+++ llvm/lib/Analysis/DemandedBits.cpp
@@ -191,6 +191,8 @@
       AB = determineLiveOperandBitsSub(OperandNo, AOut, Known, Known2);
     }
     break;
+  case Instruction::UDiv:
+  case Instruction::SDiv:
   case Instruction::Mul:
     // Find the highest live output bit. We don't need any more input
     // bits than that (adds, and thus subtracts, ripple only to the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136753.470763.patch
Type: text/x-patch
Size: 1562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221026/06916014/attachment.bin>


More information about the llvm-commits mailing list