diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2015-12-20 10:25:08 +0100 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2015-12-20 10:25:08 +0100 |
commit | 6423f1293f9bd78dd981dd6a1e8908659d46875f (patch) | |
tree | 3f2cdef0e4569663c5cd7afd40bb72eb492c055d | |
parent | 366e433a76a8c6def7dbc6f572202728aebfa65f (diff) | |
download | compcert-6423f1293f9bd78dd981dd6a1e8908659d46875f.tar.gz compcert-6423f1293f9bd78dd981dd6a1e8908659d46875f.zip |
powerpc/Asmexpand: fix expansion of __builtin_clzll
The original code produces wrong results if res and al are the same register.
-rw-r--r-- | powerpc/Asmexpand.ml | 4 |
1 files changed, 2 insertions, 2 deletions
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)) |