[PATCH] D98299: [InstSimplify] Simplify smul.fix and smul.fix.sat

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 11 01:23:55 PST 2021


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:5765
+    if (Q.isUndefValue(Op1))
+      return Constant::getNullValue(ReturnType);
+
----------------
nagisa wrote:
> Wouldn't this fail to trigger if the intrinsic call starts as follows?
> 
> ```
> lang=llvm
> %res = call i16 @llvm.smul.fix.i16(i16 42, i16 undef, i32 ...)
> ```
> 
> If I understand it correctly, the canonicalization step above would swap the two operands, making the `Op0 = undef` and `Op1 = 42`, thus preventing this simplification from happening.
> 
> (This does not appear to be an issue for `0`, it seems there's code somewhere else that const-evaluates this operation if both operands are constant)
Folding a call with all constant arguments is the responsibility of ConstantFolding rather than InstSimplify. Possibly the current constant folding implementation for fix-point multiplication doesn't handle undefs though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98299



More information about the llvm-commits mailing list