[PATCH] D24542: Make vector operation with variable index unsafe to speculate

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 19 10:20:23 PDT 2016


efriedma added a subscriber: efriedma.
efriedma added a comment.

LangRef says "If idx exceeds the length of val, the results are undefined."  That implies that the operation itself isn't undefined behavior, and therefore it's safe to speculate.

That said, the current implementation of DAGTypeLegalizer::GetVectorElementPointer can lead to undefined behavior... so we need to either fix that to mask the index, or change LangRef.  I would lean towards fixing GetVectorElementPointer.


================
Comment at: lib/Analysis/ValueTracking.cpp:3239
@@ +3238,3 @@
+  case Instruction::ExtractElement:
+    return isa<Constant>(Inst->getOperand(1));
+  case Instruction::InsertElement:
----------------
`isa<Constant>` doesn't prove anything useful.


https://reviews.llvm.org/D24542





More information about the llvm-commits mailing list