[clang] [InstCombine] Convert or concat to fshl if opposite or concat exists (PR #68502)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 19 10:52:10 PDT 2023


================
@@ -2840,6 +2841,46 @@ static Instruction *matchFunnelShift(Instruction &Or, InstCombinerImpl &IC) {
       return nullptr;
 
     FShiftArgs = {ShVal0, ShVal1, ShAmt};
+  } else if (isa<ZExtInst>(Or0) || isa<ZExtInst>(Or1)) {
+    // If there are two 'or' instructions concat variables in opposite order,
+    // the latter one can be safely convert to fshl.
+    //
+    // LowHigh = or (shl (zext Low), Width - ZextHighShlAmt), (zext High)
+    // HighLow = or (shl (zext High), ZextHighShlAmt), (zext Low)
+    // ->
+    // HighLow = fshl LowHigh, LowHigh, ZextHighShlAmt
----------------
goldsteinn wrote:

Comment doesn't seem to match the code.

Seem to matching:
`LowHigh = (zext (or Shl, Low, Width-ZExtHighShlAmt), High))`, (likewise for high). Not `zext` on the `or` operands.

https://github.com/llvm/llvm-project/pull/68502


More information about the cfe-commits mailing list