From 6423f1293f9bd78dd981dd6a1e8908659d46875f Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Sun, 20 Dec 2015 10:25:08 +0100 Subject: powerpc/Asmexpand: fix expansion of __builtin_clzll The original code produces wrong results if res and al are the same register. --- powerpc/Asmexpand.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'powerpc/Asmexpand.ml') diff --git a/powerpc/Asmexpand.ml b/powerpc/Asmexpand.ml index ca166fd1..7af27d20 100644 --- a/powerpc/Asmexpand.ml +++ b/powerpc/Asmexpand.ml @@ -363,13 +363,13 @@ let expand_builtin_inline name args res = emit (Pcntlzw(res, a1)) | "__builtin_clzll", [BA_splitlong(BA(IR ah), BA(IR al))], BR(IR res) -> let lbl = new_label () in + emit (Pcntlzw(GPR0, al)); emit (Pcntlzw(res, ah)); (* less than 32 bits zero? *) emit (Pcmpwi (res, Cint _32)); emit (Pbf (CRbit_2, lbl)); (* high bits all zero, count bits in low word and increment by 32 *) - emit (Pcntlzw(res, al)); - emit (Paddi(res, res, Cint _32)); + emit (Padd(res, res, GPR0)); emit (Plabel lbl) | "__builtin_cmpb", [BA(IR a1); BA(IR a2)], BR(IR res) -> emit (Pcmpb (res,a1,a2)) -- cgit