[PATCH] D115924: [ConstantFolding] Unify handling of load from uniform value

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 17 07:27:13 PST 2021


nikic added inline comments.


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:718
+    return UndefValue::get(Ty);
+  if (C->isNullValue() && !Ty->isX86_MMXTy() && !Ty->isX86_AMXTy())
+    return Constant::getNullValue(Ty);
----------------
ayrivera wrote:
> Is there a chance that Ty is not X86_MMX neither X86_AMX and C is NullValue(), but getNullValue doesn't support the type? For example, assume that Ty is a Function type, then in that case getNullValue will default into the llvm_unreachable.
I believe other problematic types cannot appear as a load or bitcast type. You can't load a function type (only a pointer to a function type).


================
Comment at: llvm/lib/Analysis/ConstantFolding.cpp:722
+      (Ty->isIntegerTy() || Ty->isFloatingPointTy() || Ty->isVectorTy()) &&
+      !Ty->isX86_AMXTy() && !Ty->isX86_MMXTy() && !Ty->isPtrOrPtrVectorTy())
+    return Constant::getAllOnesValue(Ty);
----------------
ayrivera wrote:
> If Ty is integer, or FP, or vector, can it be X86_AMX, X86_MMX or PtrOrPtrVector? Of not, then I think the extra check can be removed.
Yeah, this condition was too complicated. We only need to check for int, fp or vector of them.


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

https://reviews.llvm.org/D115924



More information about the llvm-commits mailing list