[llvm-branch-commits] [llvm] DAG: Preserve more flags when expanding gep (PR #110815)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Oct 2 07:27:01 PDT 2024


================
@@ -4386,34 +4386,54 @@ void SelectionDAGBuilder::visitGetElementPtr(const User &I) {
       // it.
       IdxN = DAG.getSExtOrTrunc(IdxN, dl, N.getValueType());
 
+      SDNodeFlags ScaleFlags;
+      // The multiplication of an index by the type size does not wrap the
+      // pointer index type in a signed sense (mul nsw).
+      if (NW.hasNoUnsignedSignedWrap())
+        ScaleFlags.setNoSignedWrap(true);
+
+      // The multiplication of an index by the type size does not wrap the
+      // pointer index type in an unsigned sense (mul nuw).
+      if (NW.hasNoUnsignedWrap())
+        ScaleFlags.setNoUnsignedWrap(true);
----------------
goldsteinn wrote:

`ScaleFlags.setNoUnsignedWrap(NW.hasNoUnsignedWrap())`;

Likewise above.

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


More information about the llvm-branch-commits mailing list