[PATCH] D24311: Implement MS _rot intrinsics

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 7 13:49:29 PDT 2016


rnk added inline comments.

================
Comment at: lib/CodeGen/CGBuiltin.cpp:740
@@ +739,3 @@
+    Value *LeftShifted = Builder.CreateShl(Val, Shift);
+    Value *RightShifted = Builder.CreateLShr(Val, RightShift);
+    Value *Shifted = Builder.CreateOr(LeftShifted, RightShifted);
----------------
I don't think this is correct when rotating by zero. That will cause us to shift right by ArgTypeSize, which will result in an undefined value: http://llvm.org/docs/LangRef.html#lshr-instruction

I think we need to generate a select or conditional branch as in the original code.

================
Comment at: test/CodeGen/ms-intrinsics-rotations.c:138
@@ +137,3 @@
+
+// CHECK-64BIT-LONG: i64 @test_lrotr
+// CHECK-64BIT-LONG:   [[SHIFT:%[0-9]+]] = and i64 %shift, 63
----------------
Nice, testing both LP64 and LLP64. :)


https://reviews.llvm.org/D24311





More information about the cfe-commits mailing list